]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/icap/History.cc
2 * Copyright (C) 1996-2016 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():
16 logType(LOG_TAG_NONE
),
20 memset(¤tStart
, 0, sizeof(currentStart
));
21 memset(&pastTime
, 0, sizeof(pastTime
));
24 void Adaptation::Icap::History::start(const char *context
)
26 if (!concurrencyLevel
++)
27 currentStart
= current_time
;
29 debugs(93,4, HERE
<< "start " << context
<< " level=" << concurrencyLevel
30 << " time=" << tvToMsec(pastTime
) << ' ' << this);
33 void Adaptation::Icap::History::stop(const char *context
)
35 if (!concurrencyLevel
) {
36 debugs(93, DBG_IMPORTANT
, HERE
<< "Internal error: poor history accounting " << this);
40 struct timeval current
;
42 debugs(93,4, HERE
<< "stop " << context
<< " level=" << concurrencyLevel
<<
43 " time=" << tvToMsec(pastTime
) << '+' << tvToMsec(current
) << ' ' << this);
45 if (!--concurrencyLevel
)
46 tvAssignAdd(pastTime
, current
);
50 Adaptation::Icap::History::processingTime(timeval
&total
) const
53 tvAssignAdd(total
, pastTime
);
54 debugs(93,7, HERE
<< " current total: " << tvToMsec(total
) << ' ' << this);
58 Adaptation::Icap::History::currentTime(timeval
¤t
) const
60 if (concurrencyLevel
> 0)
61 tvSub(current
, currentStart
, current_time
);