9d12a393ede828164540c0f0661663ed8026d295
[m6w6/libmemcached] / src / bin / contrib / memaslap / ms_stats.h
1 /*
2 +--------------------------------------------------------------------+
3 | libmemcached - C/C++ Client Library for memcached |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted under the terms of the BSD license. |
7 | You should have received a copy of the license in a bundled file |
8 | named LICENSE; in case you did not receive a copy you can review |
9 | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
10 +--------------------------------------------------------------------+
11 | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
12 | Copyright (c) 2020 Michael Wallner <mike@php.net> |
13 +--------------------------------------------------------------------+
14 */
15
16 #ifndef MS_STAT_H
17 #define MS_STAT_H
18
19 #include <math.h>
20 #include <unistd.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <stdint.h>
24 #include <string.h>
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 /* statistic structure of response time */
31 typedef struct {
32 char *name;
33 uint64_t total_time;
34 uint64_t min_time;
35 uint64_t max_time;
36 uint64_t get_miss;
37 uint64_t dist[65];
38 double squares;
39 double log_product;
40
41 uint64_t period_min_time;
42 uint64_t period_max_time;
43 uint64_t pre_get_miss;
44 uint64_t pre_events;
45 uint64_t pre_total_time;
46 uint64_t pre_squares;
47 double pre_log_product;
48 } ms_stat_t;
49
50 /* initialize statistic */
51 void ms_init_stats(ms_stat_t *stat, const char *name);
52
53 /* record one event */
54 void ms_record_event(ms_stat_t *stat, uint64_t time, int get_miss);
55
56 /* dump the statistics */
57 void ms_dump_stats(ms_stat_t *stat);
58
59 /* dump the format statistics */
60 void ms_dump_format_stats(ms_stat_t *stat, int run_time, int freq, int obj_size);
61
62 #ifdef __cplusplus
63 }
64 #endif
65
66 #endif /* MS_STAT_H */