]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/SBufStatsAction.cc
2 * Copyright (C) 1996-2014 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 "ipc/Messages.h"
11 #include "ipc/TypedMsgHdr.h"
12 #include "mgr/Registration.h"
13 #include "SBufDetailedStats.h"
14 #include "SBufStatsAction.h"
15 #include "StoreEntryStream.h"
17 SBufStatsAction::SBufStatsAction(const Mgr::CommandPointer
&cmd_
):
19 { } //default constructor is OK for data member
21 SBufStatsAction::Pointer
22 SBufStatsAction::Create(const Mgr::CommandPointer
&cmd
)
24 return new SBufStatsAction(cmd
);
28 SBufStatsAction::add(const Mgr::Action
& action
)
30 sbdata
+= dynamic_cast<const SBufStatsAction
&>(action
).sbdata
;
31 mbdata
+= dynamic_cast<const SBufStatsAction
&>(action
).mbdata
;
32 sbsizesatdestruct
+= dynamic_cast<const SBufStatsAction
&>(action
).sbsizesatdestruct
;
33 mbsizesatdestruct
+= dynamic_cast<const SBufStatsAction
&>(action
).mbsizesatdestruct
;
37 SBufStatsAction::collect()
39 sbdata
= SBuf::GetStats();
40 mbdata
= MemBlob::GetStats();
41 sbsizesatdestruct
= *collectSBufDestructTimeStats();
42 mbsizesatdestruct
= *collectMemBlobDestructTimeStats();
46 statHistSBufDumper(StoreEntry
* sentry
, int idx
, double val
, double size
, int count
)
50 storeAppendPrintf(sentry
, "\t%d-%d\t%d\n", static_cast<int>(val
), static_cast<int>(val
+size
), count
);
54 SBufStatsAction::dump(StoreEntry
* entry
)
56 StoreEntryStream
ses(entry
);
57 ses
<< "\n\n\nThese statistics are experimental; their format and contents "
58 "should not be relied upon, they are bound to change as "
59 "the SBuf feature is evolved\n";
63 ses
<< "SBuf size distribution at destruct time:\n";
64 sbsizesatdestruct
.dump(entry
,statHistSBufDumper
);
65 ses
<< "MemBlob capacity distribution at destruct time:\n";
66 mbsizesatdestruct
.dump(entry
,statHistSBufDumper
);
70 SBufStatsAction::pack(Ipc::TypedMsgHdr
& msg
) const
72 msg
.setType(Ipc::mtCacheMgrResponse
);
78 SBufStatsAction::unpack(const Ipc::TypedMsgHdr
& msg
)
80 msg
.checkType(Ipc::mtCacheMgrResponse
);
85 static const bool Registered
= (Mgr::RegisterAction("sbuf",
86 "String-Buffer statistics", &SBufStatsAction::Create
, 0 , 1),