~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to include/profiling.h

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2006-11-11 10:32:06 UTC
  • Revision ID: james.westby@ubuntu.com-20061111103206-f3p0r9g0vq44rp3r
Tags: upstream-3.0.PRE5
ImportĀ upstreamĀ versionĀ 3.0.PRE5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#ifndef _PROFILING_H_
 
3
#define _PROFILING_H_
 
4
 
 
5
#include "config.h"
 
6
 
 
7
/* forward decls (C++ only) */
 
8
#if __cplusplus
 
9
 
 
10
class CacheManager;
 
11
#endif
 
12
 
 
13
#ifdef USE_XPROF_STATS
 
14
 
 
15
#if !defined(_SQUID_SOLARIS_)
 
16
typedef int64_t  hrtime_t;
 
17
#else
 
18
#include <sys/time.h>
 
19
#endif
 
20
 
 
21
#if defined(__i386) || defined(__i386__)
 
22
static inline hrtime_t
 
23
get_tick(void)
 
24
{
 
25
    hrtime_t regs;
 
26
 
 
27
asm volatile ("rdtsc":"=A" (regs));
 
28
    return regs;
 
29
    /* We need return value, we rely on CC to optimise out needless subf calls */
 
30
    /* Note that "rdtsc" is relatively slow OP and stalls the CPU pipes, so use it wisely */
 
31
}
 
32
 
 
33
#elif defined(__alpha)
 
34
static inline hrtime_t
 
35
get_tick(void)
 
36
{
 
37
    hrtime_t regs;
 
38
 
 
39
asm volatile ("rpcc %0" : "=r" (regs));
 
40
    return regs;
 
41
}
 
42
 
 
43
#elif defined(_M_IX86) && defined(_MSC_VER) /* x86 platform on Microsoft C Compiler ONLY */
 
44
static __inline hrtime_t
 
45
get_tick(void)
 
46
{
 
47
    hrtime_t regs;
 
48
 
 
49
    __asm {
 
50
        cpuid
 
51
        rdtsc
 
52
        mov eax,DWORD PTR regs[0]
 
53
        mov edx,DWORD PTR regs[4]
 
54
    }
 
55
    return regs;
 
56
}
 
57
 
 
58
#else
 
59
#warning Unsupported CPU. Define function get_tick(). Disabling USE_XPROF_STATS...
 
60
#undef USE_XPROF_STATS
 
61
#endif
 
62
 
 
63
#endif /* USE_XPROF_STATS - maybe disabled above */
 
64
 
 
65
#ifdef USE_XPROF_STATS
 
66
 
 
67
typedef enum {
 
68
    XPROF_PROF_UNACCOUNTED,
 
69
    XPROF_PROF_OVERHEAD,
 
70
    XPROF_hash_lookup,
 
71
    XPROF_splay_splay,
 
72
    XPROF_xmalloc,
 
73
    XPROF_malloc,
 
74
    XPROF_xfree,
 
75
    XPROF_xxfree,
 
76
    XPROF_xrealloc,
 
77
    XPROF_xcalloc,
 
78
    XPROF_calloc,
 
79
    XPROF_xstrdup,
 
80
    XPROF_xstrndup,
 
81
    XPROF_xstrncpy,
 
82
    XPROF_xcountws,
 
83
    XPROF_memPoolChunkNew,
 
84
    XPROF_memPoolAlloc,
 
85
    XPROF_memPoolFree,
 
86
    XPROF_memPoolClean,
 
87
    XPROF_aclMatchAclList,
 
88
    XPROF_aclCheckFast,
 
89
    XPROF_comm_open,
 
90
    XPROF_comm_connect_addr,
 
91
    XPROF_comm_accept,
 
92
    XPROF_comm_close,
 
93
    XPROF_comm_udp_sendto,
 
94
    XPROF_commHandleWrite,
 
95
    XPROF_comm_check_incoming,
 
96
    XPROF_comm_poll_prep_pfds,
 
97
    XPROF_comm_poll_normal,
 
98
    XPROF_comm_handle_ready_fd,
 
99
    XPROF_comm_read_handler,
 
100
    XPROF_comm_write_handler,
 
101
    XPROF_storeGet,
 
102
    XPROF_storeMaintainSwapSpace,
 
103
    XPROF_storeRelease,
 
104
    XPROF_diskHandleWrite,
 
105
    XPROF_diskHandleRead,
 
106
    XPROF_file_open,
 
107
    XPROF_file_read,
 
108
    XPROF_file_write,
 
109
    XPROF_file_close,
 
110
#ifdef ESI
 
111
    XPROF_esiExpressionEval,
 
112
    XPROF_esiProcessing,
 
113
    XPROF_esiParsing,
 
114
#endif
 
115
    XPROF_storeClient_kickReads,
 
116
    XPROF_eventRun,
 
117
    XPROF_storeDirCallback,
 
118
    XPROF_comm_calliocallback,
 
119
    XPROF_CommReadCallbackData_callCallback,
 
120
    XPROF_CommAcceptCallbackData_callCallback,
 
121
    XPROF_CommWriteCallbackData_callCallback,
 
122
    XPROF_CommFillCallbackData_callCallback,
 
123
    XPROF_HttpStateData_readReply,
 
124
    XPROF_HttpStateData_processReplyBody,
 
125
    XPROF_StoreEntry_write,
 
126
    XPROF_storeGetMemSpace,
 
127
    XPROF_MemObject_write,
 
128
    XPROF_storeWriteComplete,
 
129
    XPROF_mem_hdr_write,
 
130
    XPROF_headersEnd,
 
131
    XPROF_parseHttpRequest,
 
132
    XPROF_HttpStateData_processReplyHeader,
 
133
    XPROF_MemBuf_consume,
 
134
    XPROF_MemBuf_append,
 
135
    XPROF_MemBuf_grow,
 
136
    XPROF_InvokeHandlers,
 
137
    XPROF_HttpMsg_httpMsgParseStep,
 
138
    XPROF_EventDispatcher_dispatch,
 
139
    XPROF_SignalDispatcher_dispatch,
 
140
    XPROF_Temp1,
 
141
    XPROF_Temp2,
 
142
    XPROF_Temp3,
 
143
    XPROF_clientSocketRecipient,
 
144
    XPROF_httpStart,
 
145
    XPROF_HttpParserParseReqLine,
 
146
    XPROF_httpRequestFree,
 
147
    XPROF_HttpHeaderParse,
 
148
    XPROF_HttpHeaderClean,
 
149
    XPROF_StringInitBuf,
 
150
    XPROF_StringInit,
 
151
    XPROF_StringLimitInit,
 
152
    XPROF_StringClean,
 
153
    XPROF_StringReset,
 
154
    XPROF_StringAppend,
 
155
    XPROF_HttpHeader_findEntry,
 
156
    XPROF_HttpHeader_getCc,
 
157
    XPROF_HttpHeader_getRange,
 
158
    XPROF_LAST
 
159
} xprof_type;
 
160
 
 
161
#define XP_NOBEST (hrtime_t)-1
 
162
 
 
163
typedef struct _xprof_stats_node xprof_stats_node;
 
164
 
 
165
typedef struct _xprof_stats_data xprof_stats_data;
 
166
 
 
167
struct _xprof_stats_data
 
168
{
 
169
    hrtime_t start;
 
170
    hrtime_t stop;
 
171
    hrtime_t delta;
 
172
    hrtime_t best;
 
173
    hrtime_t worst;
 
174
    hrtime_t count;
 
175
    int64_t summ;
 
176
};
 
177
 
 
178
struct _xprof_stats_node
 
179
{
 
180
    const char *name;
 
181
    xprof_stats_data accu;
 
182
    xprof_stats_data hist;
 
183
};
 
184
 
 
185
typedef xprof_stats_node TimersArray[1];
 
186
 
 
187
/* public Data */
 
188
SQUIDCEXTERN TimersArray *xprof_Timers;
 
189
SQUIDCEXTERN int xprof_nesting;
 
190
 
 
191
/* Exported functions */
 
192
SQUIDCEXTERN void xprof_start(xprof_type type, const char *timer);
 
193
SQUIDCEXTERN void xprof_stop(xprof_type type, const char *timer);
 
194
SQUIDCEXTERN void xprof_event(void *data);
 
195
#if __cplusplus
 
196
extern void xprofRegisterWithCacheManager(CacheManager & manager);
 
197
#endif
 
198
 
 
199
#define PROF_start(type) xprof_start(XPROF_##type, #type)
 
200
#define PROF_stop(type) xprof_stop(XPROF_##type, #type)
 
201
 
 
202
#else /* USE_XPROF_STATS */
 
203
 
 
204
#define PROF_start(ARGS) ((void)0)
 
205
#define PROF_stop(ARGS) ((void)0)
 
206
 
 
207
#endif /* USE_XPROF_STATS */
 
208
 
 
209
#endif /* _PROFILING_H_ */