measure.ci 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. /*
  2. * Part of Scheme 48 1.9. See file COPYING for notices and license.
  3. *
  4. * Authors: David Frese, Christos Freris, Eric Knauel
  5. */
  6. /* This file needs to be included from generation_gc.c, because for
  7. reasons of simplicity we use static variables from there directly
  8. here. */
  9. /* Not really sure if this is true:
  10. MEASURE_GC was an old flag by Norbert, which activated writing out
  11. several files with Sexps, containing the size of the heap, the
  12. areas, and some timing information. Most (all?) of it is actually
  13. stripped off here with "#if 0".
  14. S48_MEASURE_GC_TIME is the newer flag by Christos, used to write
  15. out gnuplot files with detailed timing informations and size
  16. informations that are taking out of the same variables as
  17. MEASURE_GC did.
  18. DISPLAY_MEASURE_GC additionally prints out some infos to stdout
  19. about what's going on with the measurement.
  20. This should be made less confusing and working properly.
  21. -- David
  22. */
  23. FILE* datafile;
  24. /* controlled by s48_collect: */
  25. void start_measure() {
  26. datafile = fopen("MEASURE-GC", "a");
  27. fprintf(datafile, " ( ");
  28. }
  29. void stop_measure() {
  30. fprintf(datafile, " ) \n \n");
  31. fclose(datafile);
  32. }
  33. static unsigned long count_collection = 0;
  34. /* write-barrier and inter-generational-pointer */
  35. static unsigned int count_wb = 0;
  36. static unsigned int count_gc_wb = 0;
  37. static unsigned int count_igp = 0;
  38. static unsigned int count_gc_igp = 0;
  39. /* visited and passed areas from trace_areas_roots */
  40. static unsigned long count_areas_roots_visited = 0;
  41. static unsigned long count_areas_roots_passed = 0;
  42. /* the heap usage and size */
  43. static unsigned long count_heap_size = 0;
  44. static unsigned long count_heap_usage = 0;
  45. static unsigned long old_heap_size = 0;
  46. unsigned long get_wbarrier() {
  47. return count_wb;
  48. }
  49. unsigned long get_gc_wbarrier() {
  50. return count_gc_wb;
  51. }
  52. unsigned long get_igen() {
  53. return count_igp;
  54. }
  55. unsigned long get_gc_igen() {
  56. return count_gc_igp;
  57. }
  58. int write_area_size(int size, int gens[]){
  59. int i;
  60. fprintf(datafile, " (areasize ");
  61. /* the creation space: */
  62. fprintf(datafile, " %d ", gens[size]);
  63. for(i = 0; i < size; i++){
  64. /* the generations: */
  65. fprintf(datafile, " %d ", gens[i]);
  66. }
  67. fprintf(datafile, " ) ");
  68. return 0;
  69. }
  70. /* mark_cons ratio */
  71. int write_mc_ratio() {
  72. double r = ((double) count_heap_usage) /
  73. ((double) (count_heap_size - count_heap_usage));
  74. fprintf(datafile, " (mcratio ");
  75. fprintf(datafile, " %f", r);
  76. fprintf(datafile, " ) ");
  77. return 0;
  78. }
  79. int write_heap_usage_size(){
  80. fprintf(datafile, " (heap ");
  81. fprintf(datafile, " %d ", count_heap_size);
  82. fprintf(datafile, " %d ", count_heap_usage);
  83. fprintf(datafile, " ) ");
  84. return 0;
  85. }
  86. /*sum of write-barrier calls and created inter-generational-pointer*/
  87. int write_wb_igp(){
  88. fprintf(datafile, " (wb ");
  89. fprintf(datafile, " %d", count_wb);
  90. fprintf(datafile, " %d", count_igp);
  91. fprintf(datafile, " ) ");
  92. return 0;
  93. }
  94. /* which generation is collected */
  95. int write_minor_major_gc(int n){
  96. fprintf(datafile, " (gens ");
  97. fprintf(datafile, " %d ", n); /* collect the first n gens */
  98. fprintf(datafile, " %d ", count_collection); /* collection number */
  99. fprintf(datafile, " ) ");
  100. return 0;
  101. }
  102. /* ratio of vistied/passed areas in trace_areas_roots */
  103. int write_areas_roots_ratio(){
  104. double ratio = ((((double) count_areas_roots_passed) /
  105. ((double) count_areas_roots_visited)) * 100);
  106. fprintf(datafile, " (arearoots ");
  107. fprintf(datafile, " %f ", ratio);
  108. fprintf(datafile, " ) ");
  109. return 0;
  110. }
  111. /* -- the "#ifdef" functions: -- */
  112. /* writing some data just before the collection:*/
  113. /************************************************************************
  114. called in: <file>::<function>
  115. ./c/bibop/generation_gc.c::s48_collect
  116. *************************************************************************/
  117. void measure_gc_start(int c){
  118. count_collection++;
  119. if (old_heap_size < count_heap_size){
  120. old_heap_size = count_heap_size;
  121. }
  122. start_measure(); /* opens fileport */
  123. write_minor_major_gc(c);
  124. write_heap_usage_size();
  125. /* small and large area numbers are invoked in s48_collect*/
  126. }
  127. /* next gc (in generation n) is triggerd and finished */
  128. /************************************************************************
  129. called in: <file>::<function>
  130. ./c/bibop/generation_gc.c::s48_collect
  131. *************************************************************************/
  132. void measure_gc_end() {
  133. write_mc_ratio();
  134. write_heap_usage_size();
  135. write_wb_igp();
  136. write_areas_roots_ratio();
  137. stop_measure(); /* closes fileport */
  138. }
  139. /************************************************************************
  140. called in: ./c/bibop/area_roots.c::s48_write_barrier
  141. *************************************************************************/
  142. void measure_write_barrier(char flag) {
  143. if (flag){
  144. /* so we have a inter-gen-pointer..*/
  145. count_igp++;
  146. }
  147. count_wb++;
  148. }
  149. /************************************************************************
  150. called in:./c/bibop/area_roots.c::s48_write_internal_barrier
  151. *************************************************************************/
  152. void measure_gc_write_barrier() {
  153. /* when we call this we have a new inter-gen-pointer..*/
  154. count_gc_igp++;
  155. count_gc_wb++;
  156. }
  157. /* number of small/large areas per generation */
  158. /************************************************************************
  159. called in: <file>::<function>
  160. ./c/bibop/generation_gc.c::get_area_objects
  161. *************************************************************************/
  162. void measure_small_areas(int size, int small[]){
  163. write_area_size(size, small);
  164. }
  165. /************************************************************************
  166. called in: <file>::<function>
  167. ./c/bibop/generation_gc.c::get_area_objects
  168. *************************************************************************/
  169. void measure_large_areas(int size, int large[]){
  170. write_area_size(size, large);
  171. }
  172. /* get the data from trace_areas_roots() */
  173. /************************************************************************
  174. called in: <file>::<function>
  175. ./c/bibop/area_roots.c::s48_trace_areas_roots
  176. *************************************************************************/
  177. void measure_areas_roots(unsigned long visited, unsigned long passed){
  178. count_areas_roots_visited += visited;
  179. count_areas_roots_passed += passed;
  180. }
  181. /************************************************************************
  182. called in: <file>::<function>
  183. ./c/bibop/generation_gc.c::s48_collect
  184. *************************************************************************/
  185. void measure_heap_size(unsigned long size){
  186. count_heap_size = size;
  187. }
  188. /************************************************************************
  189. called in: ./c/bibop/generation_gc.c::s48_collect
  190. *************************************************************************/
  191. void measure_heap_usage(unsigned long usage){
  192. count_heap_usage = usage;
  193. }
  194. /************************************************************************
  195. called in: ./c/bibop/generation_gc.c::s48_collect
  196. *************************************************************************/
  197. void clear_measurement(){
  198. count_wb = 0;
  199. count_igp = 0;
  200. count_areas_roots_passed = 0;
  201. count_areas_roots_visited = 0;
  202. count_gc_wb = 0;
  203. count_gc_igp = 0;
  204. }
  205. unsigned long get_areas_size(Area* areas) {
  206. unsigned long size = 0;
  207. FOR_ALL_AREAS(areas,
  208. size += (area->frontier - area->start));
  209. return size;
  210. }
  211. typedef struct {
  212. unsigned long gen_small_current; /* generation small area current */
  213. unsigned long gen_small_other; /* generation small area other */
  214. unsigned long gen_large_current; /* generation large area current */
  215. unsigned long gen_large_other; /* generation large area other */
  216. unsigned long gen_weaks_current; /* generation weaks area current */
  217. unsigned long gen_weaks_other; /* generation weaks area other */
  218. } GenImg;
  219. typedef struct {
  220. unsigned long gc_nr; /* collection number */
  221. unsigned long cs_small_below; /* creation space small below area */
  222. unsigned long cs_small_above; /* creation space small above area */
  223. unsigned long cs_large; /* creation space large area */
  224. unsigned long cs_weaks; /* creation space weaks area */
  225. unsigned long wbarrier; /* write barrier calls */
  226. unsigned long igen; /* intergenerational pointers (old->young) */
  227. unsigned long gc_wbarrier; /* internal write barrier calls */
  228. unsigned long gc_igen; /* internal intergenerational pointers (old->young) */
  229. /* Generations */
  230. GenImg genImgs[S48_GENERATIONS_COUNT];
  231. } HeapImg;
  232. void takeHeapImg(HeapImg* hi) {
  233. int i;
  234. hi->gc_nr = s48_gc_count();
  235. hi->cs_small_below = get_areas_size(creation_space.small_below);
  236. hi->cs_small_above = get_areas_size(creation_space.small_above);
  237. hi->cs_large = get_areas_size(creation_space.large);
  238. hi->cs_weaks = get_areas_size(creation_space.weaks);
  239. hi->wbarrier = get_wbarrier(); /* measure.h */
  240. hi->gc_wbarrier = get_gc_wbarrier(); /* measure.h */
  241. hi->igen = get_igen(); /* measure.h */
  242. hi->gc_igen = get_gc_igen(); /* measure.h */
  243. for (i = 0; i < S48_GENERATIONS_COUNT; i++) {
  244. hi->genImgs[i].gen_small_current =
  245. get_areas_size(generations[i].current_space->small_area);
  246. hi->genImgs[i].gen_small_other =
  247. get_areas_size(generations[i].other_space->small_area);
  248. hi->genImgs[i].gen_large_current =
  249. get_areas_size(generations[i].current_space->large_area);
  250. hi->genImgs[i].gen_large_other =
  251. get_areas_size(generations[i].other_space->large_area);
  252. hi->genImgs[i].gen_weaks_current =
  253. get_areas_size(generations[i].current_space->weaks_area);
  254. hi->genImgs[i].gen_weaks_other =
  255. get_areas_size(generations[i].other_space->weaks_area);
  256. }
  257. }
  258. #if (DISPLAY_MEASURE_GC)
  259. void display_string(char* message) {
  260. fprintf(stdout, message);
  261. }
  262. void display_string_x(char* message, int times) {
  263. while (times > 0) {
  264. display_string(message);
  265. times--;
  266. }
  267. }
  268. void display_number(int digits, long number) {
  269. fprintf(stdout, " %0*d", digits, number);
  270. }
  271. void display_double(int digits, double n) {
  272. fprintf(stdout, " %0*.*f", digits, 3, n);
  273. }
  274. void newline() {
  275. fprintf(stdout, "\n");
  276. }
  277. void space() {
  278. fprintf(stdout, " ");
  279. }
  280. void dis_string(char* message) {
  281. display_string(message);
  282. newline();
  283. }
  284. void dis_string_x(char* message, int times) {
  285. display_string_x(message, times);
  286. newline();
  287. }
  288. void dis_number(int digits, long n) {
  289. display_number(digits, n);
  290. newline();
  291. }
  292. void dis_double(int digits, double n) {
  293. display_double(digits, n);
  294. newline();
  295. }
  296. void display_comparison(long new, long old) {
  297. if (new == old) {
  298. display_string(" ");
  299. }
  300. else if (new > old) {
  301. display_string(" +");
  302. }
  303. else display_string(" -");
  304. }
  305. void write_vm_options(FILE* f) {
  306. fprintf(f,
  307. "VM (scheme48) Compiled with these Options\n"
  308. "-----------------------------------------\n"
  309. "S48_MEASURE_GC_TIME: %02d\n"
  310. "MEASURE_GC: %02d\n"
  311. "DISPLAY_MEASURE_GC: %02d\n"
  312. "S48_GENERATIONS_COUNT: %03d\n"
  313. "S48_CREATION_SPACE_SIZE: %03d\n"
  314. "S48_DEFAULT_WATER_MARK: %03d\n"
  315. "S48_ADJUST_WATER_MARK: %02d\n"
  316. "S48_SMALL_OBJECT_LIMIT: %05d\n"
  317. "S48_MINIMUM_SMALL_AREA_SIZE: %03d\n"
  318. "S48_MAXIMUM_SMALL_AREA_SIZE: %03d\n"
  319. "S48_MAXIMUM_LARGE_CREATION_SPACE_SIZE: %05d\n"
  320. "S48_MINIMUM_WEAK_AREA_SIZE: %05d\n"
  321. "S48_MAXIMUM_WEAK_AREA_SIZE: %05d\n"
  322. "S48_COLLECTION_THRESHOLD: %05d\n"
  323. "S48_LOG_CARD_SIZE: %03d\n"
  324. "S48_DIRTY_VECTOR_METHOD: %02d\n"
  325. "S48_WRITE_BARRIER_COMPLEXITY: %02d\n"
  326. "S48_USE_CARD_GENERATION_INDEXING: %02d\n"
  327. "S48_USE_GENERATION_INDEXING: %02d\n"
  328. "S48_USE_REMEMBERED_SETS: %02d\n",
  329. S48_MEASURE_GC_TIME,
  330. MEASURE_GC,
  331. DISPLAY_MEASURE_GC,
  332. S48_GENERATIONS_COUNT,
  333. S48_CREATION_SPACE_SIZE,
  334. S48_DEFAULT_WATER_MARK,
  335. S48_ADJUST_WATER_MARK,
  336. S48_SMALL_OBJECT_LIMIT,
  337. S48_MINIMUM_SMALL_AREA_SIZE,
  338. S48_MAXIMUM_SMALL_AREA_SIZE,
  339. S48_MAXIMUM_LARGE_CREATION_SPACE_SIZE,
  340. S48_MINIMUM_WEAK_AREA_SIZE,
  341. S48_MAXIMUM_WEAK_AREA_SIZE,
  342. S48_COLLECTION_THRESHOLD,
  343. S48_LOG_CARD_SIZE,
  344. S48_DIRTY_VECTOR_METHOD,
  345. S48_WRITE_BARRIER_COMPLEXITY,
  346. S48_USE_CARD_GENERATION_INDEXING,
  347. S48_USE_GENERATION_INDEXING,
  348. S48_USE_REMEMBERED_SETS);
  349. #if (S48_USE_REMEMBERED_SETS)
  350. fprintf(f,
  351. "S48_REMEMBERED_SET_SIZE: %05d\n"
  352. "S48_REMEMBERED_SET_TYPE: %02d\n"
  353. "S48_UNIQUE_REMEMBERED_SET: %02d\n",
  354. S48_REMEMBERED_SET_SIZE,
  355. S48_REMEMBERED_SET_TYPE,
  356. S48_UNIQUE_REMEMBERED_SET);
  357. #endif /* #if (S48_USE_REMEMBERED_SETS) */
  358. fprintf(f,
  359. "S48_USE_RDM: %02d\n",
  360. S48_USE_RDM);
  361. #if (S48_USE_RDM)
  362. fprintf(f,
  363. "S48_RDM_MAX_SIZE: %05d\n"
  364. "S48_RDM_INITIAL_THRESHOLD: %05d\n"
  365. "S48_RDM_MIN_THRESHOLD: %05d",
  366. S48_RDM_MAX_SIZE,
  367. S48_RDM_INITIAL_THRESHOLD,
  368. S48_RDM_MIN_THRESHOLD);
  369. #endif /* #if (S48_USE_RDM) */
  370. fprintf(f, "\n\n");
  371. }
  372. void display_vm_options() {
  373. write_vm_options(stdout);
  374. }
  375. #endif
  376. FILE* file;
  377. static unsigned long gc_nr = 0;
  378. static double gc_time = 0;
  379. static double gc_runtime = 0;
  380. static unsigned long total_gc_time_in_usec = 0;
  381. static double gc_average_time = 0;
  382. static unsigned long heap_size_before = 0;
  383. static unsigned long heap_size_after = 0;
  384. static unsigned long max_heap = 0;
  385. static unsigned long s48_heap_size_before = 0;
  386. static unsigned long s48_heap_size_after = 0;
  387. static HeapImg heap_img_before;
  388. static HeapImg heap_img_after;
  389. static unsigned long all_surviving_obj = 0;
  390. static unsigned long first_time_flag = 0;
  391. void fprint_cs_data(FILE* f, HeapImg* img_before, HeapImg* img_after) {
  392. fprintf(f, "%8i %8i %8i %8i %8i %8i %8i %8i ",
  393. heap_img_before.cs_small_below, /* 9 */
  394. heap_img_after.cs_small_below, /* 10 */
  395. heap_img_before.cs_small_above, /* 11 */
  396. heap_img_after.cs_small_above, /* 12 */
  397. heap_img_before.cs_large, /* 13 */
  398. heap_img_after.cs_large, /* 14 */
  399. heap_img_before.cs_weaks, /* 15 */
  400. heap_img_after.cs_weaks /* 16 */
  401. );
  402. }
  403. /* wi_data = write barrier & intergenerational pointers */
  404. void fprint_wi_data(FILE* f, HeapImg* img_before, HeapImg* img_after) {
  405. fprintf(f, "%8i %8i %8i %8i",
  406. heap_img_before.wbarrier, /* 17 */
  407. heap_img_after.gc_wbarrier, /* 18 */
  408. heap_img_before.igen, /* 19 */
  409. heap_img_after.gc_igen /* 20 */
  410. );
  411. }
  412. void fprint_gen_data(FILE* f, HeapImg* img_before, HeapImg* img_after) {
  413. int i;
  414. /* Line Order: 20 + ( X * i+1)
  415. example:
  416. Line Order of: img_after->genImgs[1].gen_large_current [ 6 ]
  417. Is: 20 + ( 6 * 1+1) = 32
  418. */
  419. for (i = 0; i < S48_GENERATIONS_COUNT; i++) {
  420. fprintf(f, "%8i %8i %8i %8i %8i %8i %8i %8i %8i %8i %8i %8i ", /* X */
  421. img_before->genImgs[i].gen_small_current, /* 1 */
  422. img_after->genImgs[i].gen_small_current, /* 2 */
  423. img_before->genImgs[i].gen_small_other, /* 3 */
  424. img_after->genImgs[i].gen_small_other, /* 4 */
  425. img_before->genImgs[i].gen_large_current, /* 5 */
  426. img_after->genImgs[i].gen_large_current, /* 6 */
  427. img_before->genImgs[i].gen_large_other, /* 7 */
  428. img_after->genImgs[i].gen_large_other, /* 8 */
  429. img_before->genImgs[i].gen_weaks_current, /* 9 */
  430. img_after->genImgs[i].gen_weaks_current, /* 10 */
  431. img_before->genImgs[i].gen_weaks_other, /* 11 */
  432. img_after->genImgs[i].gen_weaks_other /* 12 */
  433. );
  434. }
  435. }
  436. void fprint_all_data (FILE* f, HeapImg* img_before, HeapImg* img_after){
  437. /* Creation Space */
  438. fprint_cs_data(f, img_before, img_after);
  439. /* Write Barrier & InterGen Pointers */
  440. fprint_wi_data(f, img_before, img_after);
  441. /* Generations */
  442. fprint_gen_data(f, img_before, img_after);
  443. }
  444. int get_small_objects(int gen){
  445. int number = 0;
  446. /* little cheat to get to the creation_space*/
  447. if(gen == S48_GENERATIONS_COUNT){
  448. FOR_ALL_AREAS(creation_space.small_below, number += 1);
  449. FOR_ALL_AREAS(creation_space.small_above, number += 1);
  450. }else{
  451. FOR_ALL_AREAS(generations[gen].current_space->small_area, number += 1);
  452. }
  453. return number;
  454. }
  455. int get_large_objects(int gen){
  456. int number = 0;
  457. if(gen == S48_GENERATIONS_COUNT){
  458. FOR_ALL_AREAS(creation_space.large, number += 1);
  459. }else{
  460. FOR_ALL_AREAS(generations[gen].current_space->large_area, number +=1);
  461. }
  462. return number;
  463. }
  464. void get_area_objects(){
  465. int small[S48_GENERATIONS_COUNT+1];
  466. int large[S48_GENERATIONS_COUNT+1];
  467. int i;
  468. for (i = 0; i <= S48_GENERATIONS_COUNT; i++){
  469. small[i] = get_small_objects(i);
  470. large[i] = get_large_objects(i);
  471. }
  472. measure_small_areas(S48_GENERATIONS_COUNT, small);
  473. measure_large_areas(S48_GENERATIONS_COUNT, large);
  474. }
  475. long time_swap;
  476. struct timeval t1;
  477. struct timeval t2;
  478. struct timeval t3;
  479. void measure_before_collection(int c) {
  480. #if 0
  481. measure_gc_start(c);
  482. all_surviving_obj = 0;
  483. get_area_objects();
  484. measure_heap_size(s48_heap_size());
  485. measure_heap_usage(s48_heap_live_size());
  486. #endif
  487. /* catch the actual heap status */
  488. takeHeapImg(&heap_img_before);
  489. heap_size_before = s48_heap_size();
  490. s48_heap_size_before = s48_heap_live_size();
  491. /* catch the time before ... */
  492. gettimeofday(&t1, 0);
  493. }
  494. void measure_after_collection(int c) {
  495. gettimeofday(&t2, 0);
  496. t3.tv_sec = (t2.tv_sec - t1.tv_sec);
  497. time_swap = t2.tv_usec - t1.tv_usec;
  498. if (time_swap < 0) {
  499. time_swap = 1000000 + time_swap;
  500. t3.tv_sec -= 1;
  501. }
  502. t3.tv_usec = time_swap;
  503. /* save some values after collection */
  504. gc_nr = s48_gc_count();
  505. total_gc_time_in_usec += t3.tv_usec;
  506. gc_time = t3.tv_usec / 1000000.0;
  507. gc_runtime = total_gc_time_in_usec / 1000000.0;
  508. gc_average_time = total_gc_time_in_usec / ( 1000000.0 * gc_nr) ;
  509. takeHeapImg(&heap_img_after);
  510. heap_size_after = s48_heap_size();
  511. s48_heap_size_after = s48_heap_live_size();
  512. max_heap = int_max(max_heap, int_max(heap_size_before, heap_size_after));
  513. #if 0
  514. measure_heap_size(s48_heap_size());
  515. measure_heap_usage(s48_heap_live_size());
  516. measure_gc_end(); /* This will null wb and igp counters */
  517. #endif
  518. #if 0
  519. file = fopen("MEASURE-GC-TIME", "a");
  520. fprintf(file, "( %d ", t3.tv_sec);
  521. fprintf(file, " %d )", t3.tv_usec);
  522. fclose(file);
  523. #endif
  524. file = fopen("MEASURE_GC_RESULT_TEMP", "w"); /* w : to overwrite */
  525. fprintf(file, "%5i %5i %6.3f %6.3f %6.3f %8i %8i %8i ",
  526. gc_nr, /* 1 */
  527. c, /* 2 up to collected gen */
  528. gc_time, /* 3 */
  529. gc_runtime, /* 4 */
  530. gc_average_time, /* 5 */
  531. heap_size_before, /* 6 */
  532. heap_size_after, /* 7 */
  533. max_heap /* 8 */
  534. );
  535. fprint_all_data(file, &heap_img_before, &heap_img_after);
  536. fprintf(file, "\n"); /*newline */
  537. fclose(file);
  538. /* Save all results in an extra file (not to overwrite) */
  539. system("cat MEASURE_GC_RESULT_TEMP >> MEASURE_ALL_GC_RESULT"); /* unistd.h */
  540. #if (DISPLAY_MEASURE_GC)
  541. /*Print config-options once */
  542. if (first_time_flag == 0) {
  543. first_time_flag = 1;
  544. display_vm_options();
  545. newline();
  546. dis_string("gc_nr gen_nr gc_time gc_runtime gc_average");
  547. dis_string_x("-", 40);
  548. }
  549. display_number(5, s48_gc_count() );
  550. display_double(5, gc_time );
  551. display_double(7, gc_runtime );
  552. display_double(5, gc_average_time );
  553. /* up to collected generations */
  554. display_number(2, c );
  555. /* the whole heap */
  556. display_number(8, heap_size_before);
  557. display_number(8, heap_size_after);
  558. display_comparison(heap_size_after, heap_size_before);
  559. /* the used heap */
  560. display_number(8, s48_heap_size_before);
  561. display_number(8, s48_heap_size_after);
  562. display_comparison(s48_heap_size_after, s48_heap_size_before);
  563. /* % relationship between the whole and the used heap */
  564. display_double(5, (s48_heap_size_after * 100.0 ) / heap_size_after);
  565. newline();
  566. /*dis_string_x("-", 65); */
  567. /*newline(); */
  568. /* s48_check_heap(0);*/
  569. /* Initializes static variables: count_igp, count_wb, count_gc_igp,
  570. count_gc_wb (measure.h) */
  571. clear_measurement();
  572. #endif
  573. }