blob: c2e31b77cacd4b3e9f3ed08930595ea5521b5eda (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#include "message_counter.h"
#include <util/stream/str.h>
using namespace NBus;
using namespace NBus::NPrivate;
TMessageCounter::TMessageCounter()
: BytesData(0)
, BytesNetwork(0)
, Count(0)
, CountCompressed(0)
, CountCompressionRequests(0)
{
}
TMessageCounter& TMessageCounter::operator+=(const TMessageCounter& that) {
BytesData += that.BytesData;
BytesNetwork += that.BytesNetwork;
Count += that.Count;
CountCompressed += that.CountCompressed;
CountCompressionRequests += that.CountCompressionRequests;
return *this;
}
TString TMessageCounter::ToString(bool reader) const {
if (reader) {
Y_ASSERT(CountCompressionRequests == 0);
}
TStringStream readValue;
readValue << Count;
if (CountCompressionRequests != 0 || CountCompressed != 0) {
readValue << " (" << CountCompressed << " compr";
if (!reader) {
readValue << ", " << CountCompressionRequests << " compr reqs";
}
readValue << ")";
}
readValue << ", ";
readValue << BytesData << "b";
if (BytesNetwork != BytesData) {
readValue << " (" << BytesNetwork << "b network)";
}
return readValue.Str();
}
|