]>
git.proxmox.com Git - ceph.git/blob - ceph/src/test/crimson/test_perfcounters.cc
4 #include <fmt/format.h>
6 #include "common/Formatter.h"
7 #include "common/perf_counters.h"
8 #include "crimson/common/perf_counters_collection.h"
10 #include <seastar/core/app-template.hh>
11 #include <seastar/core/sharded.hh>
14 PERFTEST_FIRST
= 1000000,
19 static constexpr uint64_t PERF_VAL
= 42;
21 static seastar::future
<> test_perfcounters(){
22 return crimson::common::sharded_perf_coll().start().then([] {
23 return crimson::common::sharded_perf_coll().invoke_on_all([] (auto& s
){
24 std::string name
=fmt::format("seastar-osd::shard-{}",seastar::this_shard_id());
25 PerfCountersBuilder
plb(NULL
, name
, PERFTEST_FIRST
,PERFTEST_LAST
);
26 plb
.add_u64_counter(PERFTEST_INDEX
, "perftest_count", "count perftest");
27 auto perf_logger
= plb
.create_perf_counters();
28 perf_logger
->inc(PERFTEST_INDEX
,PERF_VAL
);
29 s
.get_perf_collection()->add(perf_logger
);
32 return crimson::common::sharded_perf_coll().invoke_on_all([] (auto& s
){
33 auto pcc
= s
.get_perf_collection();
34 pcc
->with_counters([](auto& by_path
){
35 for (auto& perf_counter
: by_path
) {
36 if (PERF_VAL
!= perf_counter
.second
.perf_counters
->get(PERFTEST_INDEX
)) {
37 throw std::runtime_error("perf counter does not match");
43 return crimson::common::sharded_perf_coll().stop();
48 int main(int argc
, char** argv
)
50 seastar::app_template app
;
51 return app
.run(argc
, argv
, [&] {
52 return test_perfcounters().then([] {
53 std::cout
<< "All tests succeeded" << std::endl
;
54 }).handle_exception([] (auto eptr
) {
55 std::cout
<< "Test failure" << std::endl
;
56 return seastar::make_exception_future
<>(eptr
);