-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathstatistics.cpp
More file actions
38 lines (30 loc) · 1.13 KB
/
statistics.cpp
File metadata and controls
38 lines (30 loc) · 1.13 KB
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
// Copyright (C) 2025 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#include "statistics.h"
#ifdef ENABLE_STATISTICS
#include <array>
#include <cstddef>
#include <cstdint>
#include <thread>
#include "config/config.h"
#include "logging.h"
using namespace config;
const std::array<const char*, STATS_COUNT> stat_names{
{"deflate_count", "deflate_error_count", "deflate_qat_count",
"deflate_qat_error_count", "deflate_iaa_count", "deflate_iaa_error_count",
"deflate_zlib_count", "inflate_count", "inflate_error_count",
"inflate_qat_count", "inflate_qat_error_count", "inflate_iaa_count",
"inflate_iaa_error_count", "inflate_zlib_count"}};
thread_local std::array<uint64_t, STATS_COUNT> stats{};
void PrintStats() {
auto total_operations = stats[static_cast<size_t>(Statistic::DEFLATE_COUNT)] +
stats[static_cast<size_t>(Statistic::INFLATE_COUNT)];
if (total_operations % configs[LOG_STATS_SAMPLES] != 0) {
return;
}
LogStats("Thread: ", std::this_thread::get_id(), "\n");
for (size_t i = 0; i < stats.size(); ++i) {
LogStats(stat_names[i], " = ", stats[i], "\n");
}
}
#endif