Skip to content

Commit

Permalink
Reverting rate_observer diffs compared to develop.
Browse files Browse the repository at this point in the history
  • Loading branch information
clemahieu committed Mar 1, 2023
1 parent 90cdfa3 commit a29e4b2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
8 changes: 4 additions & 4 deletions nano/slow_test/bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ TEST (bootstrap_ascending, profile)
rate.observe (*client, nano::stat::type::bootstrap_ascending, nano::stat::detail::reply, nano::stat::dir::in);
rate.observe (*client, nano::stat::type::bootstrap_ascending, nano::stat::detail::blocks, nano::stat::dir::in);
rate.observe (*server, nano::stat::type::bootstrap_server, nano::stat::detail::blocks, nano::stat::dir::out);
rate.observe (*client, nano::stat::type::ledger, nano::stat::detail::old);
rate.observe (*client, nano::stat::type::ledger, nano::stat::detail::gap_epoch_open_pending);
rate.observe (*client, nano::stat::type::ledger, nano::stat::detail::gap_source);
rate.observe (*client, nano::stat::type::ledger, nano::stat::detail::gap_previous);
rate.observe (*client, nano::stat::type::ledger, nano::stat::detail::old, nano::stat::dir::in);
rate.observe (*client, nano::stat::type::ledger, nano::stat::detail::gap_epoch_open_pending, nano::stat::dir::in);
rate.observe (*client, nano::stat::type::ledger, nano::stat::detail::gap_source, nano::stat::dir::in);
rate.observe (*client, nano::stat::type::ledger, nano::stat::detail::gap_previous, nano::stat::dir::in);
rate.background_print (3s);

//wait_for_key ();
Expand Down
6 changes: 4 additions & 2 deletions nano/test_common/rate_observer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,17 @@ void nano::test::rate_observer::background_print_impl (std::chrono::seconds inte

void nano::test::rate_observer::print_once ()
{
std::stringstream ss;
for (auto & counter : counters)
{
const auto observation = counter->observe ();

// Convert delta milliseconds to seconds (double precision) and then divide the counter delta to get rate per second
auto per_sec = observation.delta / (observation.time_delta.count () / 1000.0);

std::cout << "rate of '" << counter->name << "': "
<< std::setw (12) << std::setprecision (2) << std::fixed << per_sec << " /s"
<< std::endl;
}
std::cout << ss.str () << std::endl;
}

void nano::test::rate_observer::observe (std::string name, std::function<int64_t ()> observe)
Expand Down
2 changes: 1 addition & 1 deletion nano/test_common/rate_observer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class rate_observer
/*
* Starts observing a particular node stat from stat container
*/
void observe (nano::node &, nano::stat::type type, nano::stat::detail detail, nano::stat::dir dir = nano::stat::dir::in);
void observe (nano::node &, nano::stat::type type, nano::stat::detail detail, nano::stat::dir dir);

private:
void background_print_impl (std::chrono::seconds interval);
Expand Down

0 comments on commit a29e4b2

Please # to comment.