Commit | Line | Data |
---|---|---|
5024c2ac JR |
1 | /* |
2 | * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com> | |
3 | * Copyright (C) 2020 Jonathan Rajotte-Julien <jonathan.rajotte-julein@efficios.com> | |
4 | * | |
5 | * SPDX-License-Identifier: MIT | |
6 | * | |
7 | */ | |
8 | #include "performance.h" | |
9 | ||
10 | #include <lttng/tracepoint.h> | |
11 | ||
12 | #include <lttng/condition/event-rule.h> | |
13 | #include <lttng/lttng.h> | |
14 | ||
15 | #include <stdbool.h> | |
16 | #include <stddef.h> | |
17 | #include <stdio.h> | |
18 | #include <stdlib.h> | |
19 | #include <string.h> | |
20 | #include <sys/time.h> | |
21 | #include <time.h> | |
22 | #include <unistd.h> | |
23 | #include <assert.h> | |
24 | ||
25 | int main(int argc, char **argv) | |
26 | { | |
27 | int ret = 0; | |
28 | int nb_hit; | |
29 | int id; | |
30 | long long sleep_ms; | |
31 | struct timespec sleep_time; | |
32 | struct timespec sleep_rm; | |
33 | ||
34 | if (argc != 4) { | |
35 | fprintf(stderr, "Missing unique_id\n"); | |
36 | fprintf(stderr, "Missing number of event \n"); | |
37 | fprintf(stderr, "Missing delay between event in ms \n"); | |
38 | fprintf(stderr, "Usage: producer id bn_event delay_ms\n"); | |
39 | ret = 1; | |
40 | goto end; | |
41 | } | |
42 | ||
43 | id = atoi(argv[1]); | |
44 | nb_hit = atoi(argv[2]); | |
45 | sleep_ms = atoll(argv[3]); | |
46 | ||
47 | sleep_time.tv_sec = sleep_ms / 1000; | |
48 | sleep_time.tv_nsec = (sleep_ms % 1000) * 1000000; | |
49 | ||
50 | for (int i = 0; i < nb_hit; i++) { | |
51 | tracepoint(performance, hit, 0, i); | |
52 | nanosleep(&sleep_time, &sleep_rm); | |
53 | } | |
54 | ||
55 | end: | |
56 | return !!ret; | |
57 | } |