SoW-2020-0003: Trace Hit Counters
[lttng-tools.git] / doc / examples / map / instrumented-app.c
1 /*
2 * Copyright (C) 2021 Francis Deslauriers <francis.deslauriers@efficios.com>
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 */
7
8 #include "tracepoint-incr-value-example.h"
9
10 #include <lttng/tracepoint.h>
11 #include <stdio.h>
12 #include <sys/time.h>
13 #include <time.h>
14 #include <unistd.h>
15
16 int main(int argc, char **argv)
17 {
18 uint64_t i;
19
20 for (i = 0; i < UINT64_MAX; i++) {
21 char time_str[64];
22 struct timeval tv;
23 time_t the_time;
24
25 gettimeofday(&tv, NULL);
26 the_time = tv.tv_sec;
27
28 strftime(time_str, sizeof(time_str), "[%m-%d-%Y] %T",
29 localtime(&the_time));
30 printf("%s.%ld - Tracing event \"trigger_example:my_event1\"\n",
31 time_str, tv.tv_usec);
32
33 tracepoint(incr_value_ex, event1, i);
34 if (i % 2 == 0) {
35 tracepoint(incr_value_ex, event2, i);
36 }
37
38 if (i % 3 == 0) {
39 tracepoint(incr_value_ex, event3, i);
40 }
41
42 sleep(1);
43 }
44 return 0;
45 }
This page took 0.030217 seconds and 5 git commands to generate.