diff options
author | Håvard Pettersen <havardpe@yahooinc.com> | 2023-02-10 10:55:52 +0000 |
---|---|---|
committer | Håvard Pettersen <havardpe@yahooinc.com> | 2023-02-10 10:55:52 +0000 |
commit | c8afc73da7388d8bc300c08ec70f348c1463310a (patch) | |
tree | 558a97f17744891ffa27d3baf71ab153963cd38b /vespalib | |
parent | 3d5e5a56b7aed8315726b203117a2b6bc2dd0d31 (diff) |
do not report stuff that never happened
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/tests/execution_profiler/execution_profiler_test.cpp | 18 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/util/execution_profiler.cpp | 4 |
2 files changed, 21 insertions, 1 deletions
diff --git a/vespalib/src/tests/execution_profiler/execution_profiler_test.cpp b/vespalib/src/tests/execution_profiler/execution_profiler_test.cpp index 969521a2a9e..d56bb1de3db 100644 --- a/vespalib/src/tests/execution_profiler/execution_profiler_test.cpp +++ b/vespalib/src/tests/execution_profiler/execution_profiler_test.cpp @@ -214,4 +214,22 @@ TEST(ExecutionProfilerTest, with_name_mapping) { EXPECT_TRUE(find_path(slime, {{"fox", 3}})); } +TEST(ExecutionProfilerTest, flat_profiling_does_not_report_tasks_with_count_0) { + Profiler profiler(-2); + { + profiler.resolve("foo"); + profiler.resolve("bar"); + profiler.start(profiler.resolve("baz")); + profiler.complete(); + } + Slime slime; + profiler.report(slime.setObject()); + fprintf(stderr, "%s\n", slime.toString().c_str()); + EXPECT_EQ(slime["profiler"].asString().make_string(), "flat"); + EXPECT_EQ(slime["topn"].asLong(), 2); + EXPECT_EQ(slime["roots"].entries(), 1); + EXPECT_EQ(slime["roots"][0]["name"].asString().make_stringref(), "baz"); + EXPECT_EQ(slime["roots"][0]["count"].asLong(), 1); +} + GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/vespa/vespalib/util/execution_profiler.cpp b/vespalib/src/vespa/vespalib/util/execution_profiler.cpp index 6c5af6cbe41..4b4af6b4165 100644 --- a/vespalib/src/vespa/vespalib/util/execution_profiler.cpp +++ b/vespalib/src/vespa/vespalib/util/execution_profiler.cpp @@ -160,7 +160,9 @@ private: std::vector<uint32_t> nodes; nodes.reserve(_nodes.size()); for (uint32_t i = 0; i < _nodes.size(); ++i) { - nodes.push_back(i); + if (_nodes[i].count > 0) { + nodes.push_back(i); + } } std::sort(nodes.begin(), nodes.end(), [&](const auto &a, const auto &b) { |