message_counter.h 956 B

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include <util/generic/string.h>
  3. #include <cstddef>
  4. namespace NBus {
  5. namespace NPrivate {
  6. struct TMessageCounter {
  7. size_t BytesData;
  8. size_t BytesNetwork;
  9. size_t Count;
  10. size_t CountCompressed;
  11. size_t CountCompressionRequests; // reader only
  12. void AddMessage(size_t bytesData, size_t bytesCompressed, bool Compressed, bool compressionRequested) {
  13. BytesData += bytesData;
  14. BytesNetwork += bytesCompressed;
  15. Count += 1;
  16. if (Compressed) {
  17. CountCompressed += 1;
  18. }
  19. if (compressionRequested) {
  20. CountCompressionRequests += 1;
  21. }
  22. }
  23. TMessageCounter& operator+=(const TMessageCounter& that);
  24. TString ToString(bool reader) const;
  25. TMessageCounter();
  26. };
  27. }
  28. }