]> git.ipfire.org Git - thirdparty/squid.git/blame - lib/profiler/Profiler.h
Source Format Enforcement (#763)
[thirdparty/squid.git] / lib / profiler / Profiler.h
CommitLineData
f0ba1a9b 1/*
f70aedc4 2 * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
f0ba1a9b
AJ
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
25f98340
AJ
9#ifndef _PROFILER_H_
10#define _PROFILER_H_
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16// NP: CPU support for get_tick() determines whether we can profile.
17// always include get_tick.h first since it may undefine USE_XPROF_STATS
18
19#include "profiler/get_tick.h"
20#include "profiler/xprof_type.h"
21
22#if !USE_XPROF_STATS
23
b616062e
AJ
24#define PROF_start(probename) ((void)0)
25#define PROF_stop(probename) ((void)0)
25f98340
AJ
26
27#else /* USE_XPROF_STATS */
28
29#define XP_NOBEST (hrtime_t)-1
30
f53969cc 31typedef struct _xprof_stats_node xprof_stats_node;
8236d34f 32
f53969cc 33typedef struct _xprof_stats_data xprof_stats_data;
8236d34f 34
f53969cc
SM
35struct _xprof_stats_data {
36 hrtime_t start;
37 hrtime_t stop;
38 hrtime_t delta;
39 hrtime_t best;
40 hrtime_t worst;
41 hrtime_t count;
42 hrtime_t accum;
43 int64_t summ;
44};
8236d34f 45
f53969cc
SM
46struct _xprof_stats_node {
47 const char *name;
48 xprof_stats_data accu;
49 xprof_stats_data hist;
50};
8236d34f 51
f53969cc 52typedef xprof_stats_node TimersArray[1];
8236d34f 53
f53969cc
SM
54/* public Data */
55extern TimersArray *xprof_Timers;
8236d34f 56
f53969cc
SM
57/* Exported functions */
58extern void xprof_start(xprof_type type, const char *timer);
59extern void xprof_stop(xprof_type type, const char *timer);
60extern void xprof_event(void *data);
25f98340 61
b616062e
AJ
62#define PROF_start(probename) xprof_start(XPROF_##probename, #probename)
63#define PROF_stop(probename) xprof_stop(XPROF_##probename, #probename)
25f98340
AJ
64
65#endif /* USE_XPROF_STATS */
66
67#ifdef __cplusplus
68}
69#endif
70#endif /* _PROFILING_H_ */
f53969cc 71