]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/icap/History.cc
2 * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
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.
10 #include "adaptation/icap/History.h"
13 #include "SquidTime.h"
15 Adaptation::Icap::History::History():
19 memset(¤tStart
, 0, sizeof(currentStart
));
20 memset(&pastTime
, 0, sizeof(pastTime
));
23 void Adaptation::Icap::History::start(const char *context
)
25 if (!concurrencyLevel
++)
26 currentStart
= current_time
;
28 debugs(93,4, HERE
<< "start " << context
<< " level=" << concurrencyLevel
29 << " time=" << tvToMsec(pastTime
) << ' ' << this);
32 void Adaptation::Icap::History::stop(const char *context
)
34 if (!concurrencyLevel
) {
35 debugs(93, DBG_IMPORTANT
, "ERROR: Squid BUG: poor history accounting " << this);
39 struct timeval current
;
41 debugs(93,4, HERE
<< "stop " << context
<< " level=" << concurrencyLevel
<<
42 " time=" << tvToMsec(pastTime
) << '+' << tvToMsec(current
) << ' ' << this);
44 if (!--concurrencyLevel
)
45 tvAssignAdd(pastTime
, current
);
49 Adaptation::Icap::History::processingTime(timeval
&total
) const
52 tvAssignAdd(total
, pastTime
);
53 debugs(93,7, HERE
<< " current total: " << tvToMsec(total
) << ' ' << this);
57 Adaptation::Icap::History::currentTime(timeval
¤t
) const
59 if (concurrencyLevel
> 0)
60 tvSub(current
, currentStart
, current_time
);