2 * Copyright (c) 2011 David Goulet <david.goulet@polymtl.ca>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
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 along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include "ltt-sessiond/session.h"
30 #include "benchmark.h"
32 #define SESSION1 "test1"
34 /* This path will NEVER be created in this test */
35 #define PATH1 "/tmp/.test-junk-lttng"
41 static const char alphanum
[] =
43 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
44 "abcdefghijklmnopqrstuvwxyz";
47 * Return random string of 10 characters.
49 static char *get_random_string(void)
52 char *str
= malloc(11);
54 for (i
= 0; i
< 10; i
++) {
55 str
[i
] = alphanum
[rand() % (sizeof(alphanum
) - 1)];
63 int main(int argc
, char **argv
)
67 double value
, total
= 0;
70 printf("Aborting test. Must be uid 0 to drop_caches\n");
75 printf("Missing arguments\n");
79 nb_iter
= atoi(argv
[1]);
81 names
= malloc(sizeof(char*) * nb_iter
);
86 fprintf(fp
, "--- Create tracing session ---\n");
87 for (i
= 0; i
< nb_iter
; i
++) {
88 names
[i
] = get_random_string();
89 ret
= system("echo 3 >/proc/sys/vm/drop_caches");
90 tracepoint(create_session_start
);
91 ret
= create_session(names
[i
], PATH1
);
92 tracepoint(create_session_end
);
94 printf("Create session went wrong. Aborting\n");
97 value
= bench_get_create_session();
98 fprintf(fp
, "%.20f\n", value
);
102 fprintf(fp
, "--> Average: %.20f\n\n", total
/nb_iter
);
105 fprintf(fp
, "--- Destroy tracing session ---\n");
106 for (i
= 0; i
< nb_iter
; i
++) {
107 ret
= system("echo 3 >/proc/sys/vm/drop_caches");
108 tracepoint(destroy_session_start
);
109 ret
= destroy_session(names
[i
]);
110 tracepoint(destroy_session_end
);
112 printf("Destroy session went wrong. Aborting\n");
115 value
= bench_get_destroy_session();
116 fprintf(fp
, "%.20f\n", value
);
120 fprintf(fp
, "--> Average: %.20f\n\n", total
/nb_iter
);
This page took 0.033071 seconds and 4 git commands to generate.