7 /* forward decls (C++ only) */
13 #ifdef USE_XPROF_STATS
15 #if !defined(_SQUID_SOLARIS_)
16 typedef int64_t hrtime_t
;
21 #if defined(__i386) || defined(__i386__)
22 static inline hrtime_t
27 asm volatile ("rdtsc":"=A" (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 */
33 #elif defined(__x86_64) || defined(__x86_64__)
34 static inline hrtime_t
38 // Based on an example in Wikipedia
39 /* We cannot use "=A", since this would use %rax on x86_64 */
40 asm volatile ("rdtsc" : "=a" (lo
), "=d" (hi
));
41 return (hrtime_t
)hi
<< 32 | lo
;
44 #elif defined(__alpha)
45 static inline hrtime_t
50 asm volatile ("rpcc %0" : "=r" (regs
));
54 #elif defined(_M_IX86) && defined(_MSC_VER) /* x86 platform on Microsoft C Compiler ONLY */
55 static __inline hrtime_t
63 mov eax
,DWORD PTR regs
[0]
64 mov edx
,DWORD PTR regs
[4]
70 #warning Unsupported CPU. Define function get_tick(). Disabling USE_XPROF_STATS...
71 #undef USE_XPROF_STATS
74 #endif /* USE_XPROF_STATS - maybe disabled above */
76 #ifdef USE_XPROF_STATS
79 XPROF_PROF_UNACCOUNTED
,
103 XPROF_memPoolChunkNew
,
107 XPROF_aclMatchAclList
,
110 XPROF_comm_connect_addr
,
113 XPROF_comm_udp_sendto
,
114 XPROF_commHandleWrite
,
115 XPROF_comm_check_incoming
,
116 XPROF_comm_poll_prep_pfds
,
117 XPROF_comm_poll_normal
,
118 XPROF_comm_handle_ready_fd
,
119 XPROF_comm_read_handler
,
120 XPROF_comm_write_handler
,
122 XPROF_storeMaintainSwapSpace
,
124 XPROF_diskHandleWrite
,
125 XPROF_diskHandleRead
,
131 XPROF_esiExpressionEval
,
135 XPROF_storeClient_kickReads
,
137 XPROF_storeDirCallback
,
138 XPROF_comm_calliocallback
,
139 XPROF_CommReadCallbackData_callCallback
,
140 XPROF_CommAcceptCallbackData_callCallback
,
141 XPROF_CommWriteCallbackData_callCallback
,
142 XPROF_CommFillCallbackData_callCallback
,
143 XPROF_HttpStateData_readReply
,
144 XPROF_HttpStateData_processReplyBody
,
145 XPROF_StoreEntry_write
,
146 XPROF_storeGetMemSpace
,
147 XPROF_MemObject_write
,
148 XPROF_storeWriteComplete
,
151 XPROF_parseHttpRequest
,
152 XPROF_HttpStateData_processReplyHeader
,
153 XPROF_MemBuf_consume
,
156 XPROF_InvokeHandlers
,
157 XPROF_HttpMsg_httpMsgParseStep
,
158 XPROF_EventDispatcher_dispatch
,
159 XPROF_SignalEngine_checkEvents
,
163 XPROF_clientSocketRecipient
,
165 XPROF_HttpParserParseReqLine
,
166 XPROF_httpRequestFree
,
167 XPROF_HttpHeaderParse
,
168 XPROF_HttpHeaderClean
,
170 XPROF_StringAllocAndFill
,
174 XPROF_HttpHeader_findEntry
,
175 XPROF_HttpHeader_getCc
,
176 XPROF_HttpHeader_getRange
,
182 #define XP_NOBEST (hrtime_t)-1
184 typedef struct _xprof_stats_node xprof_stats_node
;
186 typedef struct _xprof_stats_data xprof_stats_data
;
188 struct _xprof_stats_data
200 struct _xprof_stats_node
203 xprof_stats_data accu
;
204 xprof_stats_data hist
;
207 typedef xprof_stats_node TimersArray
[1];
210 SQUIDCEXTERN TimersArray
*xprof_Timers
;
212 /* Exported functions */
213 SQUIDCEXTERN
void xprof_start(xprof_type type
, const char *timer
);
214 SQUIDCEXTERN
void xprof_stop(xprof_type type
, const char *timer
);
215 SQUIDCEXTERN
void xprof_event(void *data
);
217 #define PROF_start(type) xprof_start(XPROF_##type, #type)
218 #define PROF_stop(type) xprof_stop(XPROF_##type, #type)
220 #else /* USE_XPROF_STATS */
222 #define PROF_start(ARGS) ((void)0)
223 #define PROF_stop(ARGS) ((void)0)
225 #endif /* USE_XPROF_STATS */
227 #endif /* _PROFILING_H_ */