convert from svn repository: remove tags directory
[lttv.git] / trunk / tests / kernel / module-template.c
CommitLineData
884367fd 1/* test-time-probe.c
2 *
3 * Test time spent in a LTTng instrumentation probe.
4 */
5
6
26c9702b 7#define CONFIG_LTT_FACILITY_TESTS
8#include "ltt-facility-tests.h"
9
884367fd 10#include <linux/init.h>
11#include <linux/module.h>
12#include <linux/ltt-core.h>
13
26c9702b 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
884367fd 21static int ltt_test_init(void)
22{
26c9702b 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;
884367fd 28 printk(KERN_ALERT "test init\n");
97dcdc7c 29
26c9702b 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);
97dcdc7c 47
26c9702b 48 printk(KERN_ALERT "test end\n");
97dcdc7c 49
50 return -EAGAIN; /* Fail will directly unload the module */
884367fd 51}
52
53static void ltt_test_exit(void)
54{
55 printk(KERN_ALERT "test exit\n");
56}
57
58module_init(ltt_test_init)
59module_exit(ltt_test_exit)
60
61MODULE_LICENSE("GPL");
62MODULE_AUTHOR("Mathieu Desnoyers");
63MODULE_DESCRIPTION("Linux Trace Toolkit Test");
64
This page took 0.03601 seconds and 4 git commands to generate.