2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; only version 2
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include "benchmark.h"
28 void benchmark_print_boot_results(void)
33 double global_boot_time
= 0.0;
35 fp
= fopen(RESULTS_FILE_NAME
, "w");
37 perror("fopen benchmark");
41 /* CPU Frequency calibration */
42 for (i
= 0; i
< nb_calib
; i
++) {
43 freq
+= get_cpu_freq();
45 freq
= freq
/ nb_calib
;
47 fprintf(fp
, "CPU frequency %lu Ghz\n\n", freq
);
49 fprintf(fp
, "Results:\n----------\n");
51 res
= (double) (((double)(time_sessiond_boot_end
- time_sessiond_boot_start
)
52 / (((double)freq
) / 1000)) / 1000000000);
54 fprintf(fp
, "Boot time inside main() from start to first pthread_join (blocking state)\n");
55 fprintf(fp
, "Time: %.20f sec.\n", res
);
57 global_boot_time
+= res
;
59 res
= (double) (((double)(time_sessiond_th_kern_poll
- time_sessiond_th_kern_start
)
60 / (((double)freq
) / 1000)) / 1000000000);
62 fprintf(fp
, "Boot time of the kernel thread from start to poll() (ready state)\n");
63 fprintf(fp
, "Time: %.20f sec.\n", res
);
65 global_boot_time
+= res
;
67 res
= (double) (((double)(time_sessiond_th_apps_poll
- time_sessiond_th_apps_start
)
68 / (((double)freq
) / 1000)) / 1000000000);
70 fprintf(fp
, "Boot time of the application thread from start to poll() (ready state)\n");
71 fprintf(fp
, "Time: %.20f sec.\n", res
);
73 global_boot_time
+= res
;
75 res
= (double) (((double)(time_sessiond_th_cli_poll
- time_sessiond_th_cli_start
)
76 / (((double)freq
) / 1000)) / 1000000000);
78 fprintf(fp
, "Boot time of the client thread from start to poll() (ready state)\n");
79 fprintf(fp
, "Time: %.20f sec.\n", res
);
81 global_boot_time
+= res
;
83 fprintf(fp
, "Global Boot Time of ltt-sessiond: %0.20f sec.\n", global_boot_time
);