Initial import of the benchmark branch
[lttng-tools.git] / benchmark / benchmark.c
1 /*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 *
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
7 * of the License.
8 *
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.
13 *
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.
17 */
18
19 #include <stdio.h>
20 #include <string.h>
21 #include <sys/time.h>
22 #include <unistd.h>
23
24 #include "benchmark.h"
25
26 static FILE *fp;
27
28 void benchmark_print_boot_results(void)
29 {
30 uint64_t freq = 0;
31 double res;
32 int i, nb_calib = 10;
33 double global_boot_time = 0.0;
34
35 fp = fopen(RESULTS_FILE_NAME, "w");
36 if (fp == NULL) {
37 perror("fopen benchmark");
38 return;
39 }
40
41 /* CPU Frequency calibration */
42 for (i = 0; i < nb_calib; i++) {
43 freq += get_cpu_freq();
44 }
45 freq = freq / nb_calib;
46
47 fprintf(fp, "CPU frequency %lu Ghz\n\n", freq);
48
49 fprintf(fp, "Results:\n----------\n");
50
51 res = (double) (((double)(time_sessiond_boot_end - time_sessiond_boot_start)
52 / (((double)freq) / 1000)) / 1000000000);
53
54 fprintf(fp, "Boot time inside main() from start to first pthread_join (blocking state)\n");
55 fprintf(fp, "Time: %.20f sec.\n", res);
56
57 global_boot_time += res;
58
59 res = (double) (((double)(time_sessiond_th_kern_poll - time_sessiond_th_kern_start)
60 / (((double)freq) / 1000)) / 1000000000);
61
62 fprintf(fp, "Boot time of the kernel thread from start to poll() (ready state)\n");
63 fprintf(fp, "Time: %.20f sec.\n", res);
64
65 global_boot_time += res;
66
67 res = (double) (((double)(time_sessiond_th_apps_poll - time_sessiond_th_apps_start)
68 / (((double)freq) / 1000)) / 1000000000);
69
70 fprintf(fp, "Boot time of the application thread from start to poll() (ready state)\n");
71 fprintf(fp, "Time: %.20f sec.\n", res);
72
73 global_boot_time += res;
74
75 res = (double) (((double)(time_sessiond_th_cli_poll - time_sessiond_th_cli_start)
76 / (((double)freq) / 1000)) / 1000000000);
77
78 fprintf(fp, "Boot time of the client thread from start to poll() (ready state)\n");
79 fprintf(fp, "Time: %.20f sec.\n", res);
80
81 global_boot_time += res;
82
83 fprintf(fp, "Global Boot Time of ltt-sessiond: %0.20f sec.\n", global_boot_time);
84
85 fclose(fp);
86 }
This page took 0.046846 seconds and 5 git commands to generate.