]> git.ipfire.org Git - thirdparty/squid.git/blob - tools/squidclient/Ping.h
Merged from trunk
[thirdparty/squid.git] / tools / squidclient / Ping.h
1 #ifndef _SQUID_TOOLS_CLIENT_PING_H
2 #define _SQUID_TOOLS_CLIENT_PING_H
3
4 /**
5 * API for looping the squidclient request message
6 * repeatedly.
7 */
8 namespace Ping
9 {
10
11 /// parameters controlling 'ping' mode message looping.
12 class TheConfig
13 {
14 public:
15 TheConfig() : enable(false), count(0), interval(1*1000) {}
16
17 /// display Ping Options command line help to stderr
18 void usage();
19
20 /**
21 * parse --ping command line options
22 * \return true if there are other options still to parse
23 */
24 bool parseCommandOpts(int argc, char *argv[], int c, int &optIndex);
25
26 bool enable;
27 int count;
28 int interval;
29 };
30
31 extern TheConfig Config;
32
33 /// initialize the squidclient ping mode
34 uint32_t Init();
35
36 /// whether ping loop is completed at the given iteration.
37 inline bool LoopDone(int i)
38 {
39 return !Ping::Config.enable || (Ping::Config.count && i >= Ping::Config.count);
40 }
41
42 /// start timing a new transaction
43 void TimerStart();
44
45 /// calculate and display the statictics for a complete transaction
46 /// \param fsize number of bytes transferred during this transaction (for KB/s measure)
47 void TimerStop(size_t fsize);
48
49 /// display summary of ping data collected
50 void DisplayStats();
51
52 } // namespace Ping
53
54 #endif /* _SQUID_TOOLS_CLIENT_PING_H */