move everything out of trunk
[lttv.git] / tests / kernel / test-time-probe.c
1 /* test-time-probe.c
2 *
3 * Test time spent in a LTTng instrumentation probe.
4 */
5
6
7 #define CONFIG_LTT_FACILITY_TESTS
8 #include "ltt-facility-tests.h"
9
10 #include <linux/init.h>
11 #include <linux/module.h>
12 #include <linux/ltt-core.h>
13
14
15 /* Event logged : 4 bytes + 20 bytes header = 24 bytes. Let's use 1MB of
16 * buffers. 1MB / 24bytes = 43690. So, if we write 20000 event, we should not
17 * lose events. Check event lost count after tests. */
18
19 #define NR_LOOPS 20000
20
21 static int ltt_test_init(void)
22 {
23 unsigned int i;
24 cycles_t time1, time2, time;
25 cycles_t max_time = 0, min_time = 18446744073709551615ULL; /* (2^64)-1 */
26 cycles_t tot_time = 0;
27 unsigned long flags;
28 printk(KERN_ALERT "test init\n");
29
30 local_irq_save(flags);
31 for(i=0; i<NR_LOOPS; i++) {
32 time1 = get_cycles();
33 trace_tests_write_4bytes(5000);
34 time2 = get_cycles();
35 time = time2 - time1;
36 max_time = max(max_time, time);
37 min_time = min(min_time, time);
38 tot_time += time;
39 }
40 local_irq_restore(flags);
41
42 printk(KERN_ALERT "test results : time per probe\n");
43 printk(KERN_ALERT "number of loops : %d\n", NR_LOOPS);
44 printk(KERN_ALERT "total time : %llu\n", tot_time);
45 printk(KERN_ALERT "min : %llu\n", min_time);
46 printk(KERN_ALERT "max : %llu\n", max_time);
47
48 printk(KERN_ALERT "test end\n");
49
50 return -EAGAIN; /* Fail will directly unload the module */
51 }
52
53 static void ltt_test_exit(void)
54 {
55 printk(KERN_ALERT "test exit\n");
56 }
57
58 module_init(ltt_test_init)
59 module_exit(ltt_test_exit)
60
61 MODULE_LICENSE("GPL");
62 MODULE_AUTHOR("Mathieu Desnoyers");
63 MODULE_DESCRIPTION("Linux Trace Toolkit Test");
64
This page took 0.030245 seconds and 4 git commands to generate.