Tests the performance of metrics fetching when there are a large number of metrics.
| 788 | // Tests the performance of metrics fetching when there |
| 789 | // are a large number of metrics. |
| 790 | TEST_P(Metrics_BENCHMARK_Test, Scalability) |
| 791 | { |
| 792 | size_t metrics_count = GetParam(); |
| 793 | |
| 794 | vector<metrics::Counter> counters; |
| 795 | counters.reserve(metrics_count); |
| 796 | |
| 797 | for (size_t i = 0; i < metrics_count; ++i) { |
| 798 | counters.push_back( |
| 799 | metrics::Counter("metrics/keys/can/be/somewhat/long/" |
| 800 | "so/we/use/a/fairly/long/key/here/" |
| 801 | "to/test/a/more/pathological/case/" + |
| 802 | stringify(i))); |
| 803 | } |
| 804 | |
| 805 | Stopwatch watch; |
| 806 | watch.start(); |
| 807 | for (size_t i = 0; i < metrics_count; ++i) { |
| 808 | metrics::add(counters[i]).get(); |
| 809 | } |
| 810 | watch.stop(); |
| 811 | |
| 812 | std::cout << "Added " << metrics_count << " counters in " |
| 813 | << watch.elapsed() << std::endl; |
| 814 | |
| 815 | watch.start(); |
| 816 | metrics::snapshot(None()).get(); |
| 817 | watch.stop(); |
| 818 | |
| 819 | std::cout << "Snapshot of " << metrics_count << " counters in " |
| 820 | << watch.elapsed() << std::endl; |
| 821 | |
| 822 | UPID upid("metrics", process::address()); |
| 823 | |
| 824 | watch.start(); |
| 825 | http::get(upid, "snapshot").get(); |
| 826 | watch.stop(); |
| 827 | |
| 828 | std::cout << "HTTP /snapshot of " << metrics_count << " counters in " |
| 829 | << watch.elapsed() << std::endl; |
| 830 | |
| 831 | watch.start(); |
| 832 | for (size_t i = 0; i < metrics_count; ++i) { |
| 833 | metrics::remove(counters[i]).get(); |
| 834 | } |
| 835 | watch.stop(); |
| 836 | |
| 837 | std::cout << "Removed " << metrics_count << " counters in " |
| 838 | << watch.elapsed() << std::endl; |
| 839 | } |
| 840 | |
| 841 | |
| 842 | TEST(ProcessTest, Process_BENCHMARK_MpscLinkedQueueEmpty) |
nothing calls this directly
no test coverage detected