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