aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2024-09-30 11:58:39 +0200
committerToni Uhlig <matzeton@googlemail.com>2024-10-01 11:58:39 +0200
commit0e792ba3011faba982e8d6bd06fb6d5e7c5a8378 (patch)
tree2038084130bcd59ce746cee9f0e74f9ad2660fdf
parent9ef17b7bd810cf46b9432345fa872b82d5e50d92 (diff)
Generate global stats with microseconds precision.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r--examples/c-analysed/c-analysed.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/examples/c-analysed/c-analysed.c b/examples/c-analysed/c-analysed.c
index 5615e075d..71ab7fa4a 100644
--- a/examples/c-analysed/c-analysed.c
+++ b/examples/c-analysed/c-analysed.c
@@ -1786,9 +1786,19 @@ static int write_global_flow_stats(void)
}
buf[-1] = '\n';
- time_t timestamp = time(NULL);
- fprintf(stats_csv_fp, "%lld,%s", (long long int)timestamp, output_buffer);
- rc = 0;
+ struct timeval tval;
+ if (gettimeofday(&tval, NULL) == 0)
+ {
+ unsigned long long int sec = tval.tv_sec;
+ unsigned long long int usec = tval.tv_usec;
+ unsigned long long int timestamp = usec + sec * 1000 * 1000;
+ fprintf(stats_csv_fp, "%llu,%s", timestamp, output_buffer);
+ rc = 0;
+ }
+ else
+ {
+ fprintf(stats_csv_fp, "0,%s", output_buffer);
+ }
failure:
// reset all counters until the analysed timer is ready again
memset(&analysed_statistics.counters, 0, sizeof(analysed_statistics.counters));