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 "lttng-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;
68 struct ltt_session
*session
;
71 printf("Aborting test. Must be uid 0 to drop_caches\n");
76 printf("Missing arguments\n");
80 nb_iter
= atoi(argv
[1]);
82 names
= malloc(sizeof(char*) * nb_iter
);
87 fprintf(fp
, "--- Create tracing session ---\n");
88 for (i
= 0; i
< nb_iter
; i
++) {
89 names
[i
] = get_random_string();
90 ret
= system("echo 3 >/proc/sys/vm/drop_caches");
91 tracepoint(create_session_start
);
92 ret
= session_create(names
[i
], PATH1
);
93 tracepoint(create_session_end
);
95 printf("Create session went wrong. Aborting\n");
98 value
= bench_get_create_session();
99 fprintf(fp
, "%.20f\n", value
);
103 fprintf(fp
, "--> Average: %.20f\n\n", total
/nb_iter
);
106 fprintf(fp
, "--- Destroy tracing session ---\n");
107 for (i
= 0; i
< nb_iter
; i
++) {
108 session
= session_find_by_name(names
[i
]);
109 ret
= system("echo 3 >/proc/sys/vm/drop_caches");
110 tracepoint(destroy_session_start
);
111 ret
= session_destroy(session
);
112 tracepoint(destroy_session_end
);
114 printf("Destroy session went wrong. Aborting\n");
117 value
= bench_get_destroy_session();
118 fprintf(fp
, "%.20f\n", value
);
122 fprintf(fp
, "--> Average: %.20f\n\n", total
/nb_iter
);
This page took 0.036809 seconds and 5 git commands to generate.