History.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
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 
9 #include "squid.h"
11 #include "debug/Stream.h"
12 #include "globals.h"
13 #include "time/gadgets.h"
14 
16  req_sz(0),
17  concurrencyLevel(0)
18 {
19  memset(&currentStart, 0, sizeof(currentStart));
20  memset(&pastTime, 0, sizeof(pastTime));
21 }
22 
23 void Adaptation::Icap::History::start(const char *context)
24 {
25  if (!concurrencyLevel++)
26  currentStart = current_time;
27 
28  debugs(93,4, "start " << context << " level=" << concurrencyLevel
29  << " time=" << tvToMsec(pastTime) << ' ' << this);
30 }
31 
32 void Adaptation::Icap::History::stop(const char *context)
33 {
34  if (!concurrencyLevel) {
35  debugs(93, DBG_IMPORTANT, "ERROR: Squid BUG: poor history accounting " << this);
36  return;
37  }
38 
39  struct timeval current;
40  currentTime(current);
41  debugs(93,4, "stop " << context << " level=" << concurrencyLevel <<
42  " time=" << tvToMsec(pastTime) << '+' << tvToMsec(current) << ' ' << this);
43 
44  if (!--concurrencyLevel)
45  tvAssignAdd(pastTime, current);
46 }
47 
48 void
50 {
51  currentTime(total);
52  tvAssignAdd(total, pastTime);
53  debugs(93,7, " current total: " << tvToMsec(total) << ' ' << this);
54 }
55 
56 void
58 {
59  if (concurrencyLevel > 0)
60  tvSub(current, currentStart, current_time);
61  else {
62  current.tv_sec = 0;
63  current.tv_usec = 0;
64  }
65 }
66 
void stop(const char *context)
note the end of an ICAP processing interval
Definition: History.cc:32
void tvAssignAdd(struct timeval &t, struct timeval const &add)
Definition: gadgets.cc:79
timeval currentStart
when the current processing interval started
Definition: History.h:51
struct timeval current_time
the current UNIX time in timeval {seconds, microseconds} format
Definition: gadgets.cc:17
void currentTime(struct timeval &) const
time since current start or zero
Definition: History.cc:57
void processingTime(struct timeval &total) const
Definition: History.cc:49
void start(const char *context)
record the start of an ICAP processing interval
Definition: History.cc:23
#define DBG_IMPORTANT
Definition: Stream.h:41
long int tvToMsec(struct timeval &t)
Definition: gadgets.h:93
struct timeval pastTime
sum of closed processing interval durations
Definition: History.h:52
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:196
void tvSub(struct timeval &res, struct timeval const &t1, struct timeval const &t2)
Definition: gadgets.cc:58

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors