From e98256f3cf3320eb1281893e5467ec221a6beb30 Mon Sep 17 00:00:00 2001 From: Elias Bermudez Date: Wed, 8 Jun 2022 13:55:37 -0700 Subject: [PATCH] Reformat to use camel case --- src/c++/perf_analyzer/inference_profiler.cc | 78 +++++++++------------ src/c++/perf_analyzer/inference_profiler.h | 12 ++-- 2 files changed, 41 insertions(+), 49 deletions(-) diff --git a/src/c++/perf_analyzer/inference_profiler.cc b/src/c++/perf_analyzer/inference_profiler.cc index c65d2f856..3f075fc25 100644 --- a/src/c++/perf_analyzer/inference_profiler.cc +++ b/src/c++/perf_analyzer/inference_profiler.cc @@ -635,9 +635,9 @@ InferenceProfiler::ProfileHelper( } } - *is_stable = determine_stability(load_status); + *is_stable = determineStability(load_status); - if (is_done_profiling(load_status, is_stable)) { + if (isDoneProfiling(load_status, is_stable)) { break; } @@ -663,7 +663,7 @@ InferenceProfiler::ProfileHelper( } bool -InferenceProfiler::determine_stability(LoadStatus& load_status) +InferenceProfiler::determineStability(LoadStatus& load_status) { bool stable = false; if (load_status.infer_per_sec.size() >= load_parameters_.stability_window) { @@ -677,21 +677,20 @@ InferenceProfiler::determine_stability(LoadStatus& load_status) } } - stable = stable && check_window_for_stability(idx, load_status); + stable = stable && checkWindowForStability(idx, load_status); } return stable; } bool -InferenceProfiler::check_window_for_stability( - size_t idx, LoadStatus& load_status) +InferenceProfiler::checkWindowForStability(size_t idx, LoadStatus& load_status) { - return is_infer_window_stable(idx, load_status) && - is_latency_window_stable(idx, load_status); + return isInferWindowStable(idx, load_status) && + isLatencyWindowStable(idx, load_status); } bool -InferenceProfiler::is_infer_window_stable(size_t idx, LoadStatus& load_status) +InferenceProfiler::isInferWindowStable(size_t idx, LoadStatus& load_status) { auto infer_start = std::begin(load_status.infer_per_sec) + idx; auto infer_per_sec_measurements = std::minmax_element( @@ -705,7 +704,7 @@ InferenceProfiler::is_infer_window_stable(size_t idx, LoadStatus& load_status) } bool -InferenceProfiler::is_latency_window_stable(size_t idx, LoadStatus& load_status) +InferenceProfiler::isLatencyWindowStable(size_t idx, LoadStatus& load_status) { auto latency_start = std::begin(load_status.latencies) + idx; auto latencies_per_sec_measurements = std::minmax_element( @@ -718,7 +717,7 @@ InferenceProfiler::is_latency_window_stable(size_t idx, LoadStatus& load_status) } bool -InferenceProfiler::is_done_profiling(LoadStatus& load_status, bool* is_stable) +InferenceProfiler::isDoneProfiling(LoadStatus& load_status, bool* is_stable) { size_t idx = load_status.infer_per_sec.size() - load_parameters_.stability_window; @@ -726,7 +725,7 @@ InferenceProfiler::is_done_profiling(LoadStatus& load_status, bool* is_stable) bool done = false; for (size_t i = idx; i < load_status.infer_per_sec.size(); i++) { - within_threshold &= check_within_threshold(idx, load_status); + within_threshold &= checkWithinThreshold(idx, load_status); } if (mpi_driver_->IsMPIRun()) { @@ -743,7 +742,7 @@ InferenceProfiler::is_done_profiling(LoadStatus& load_status, bool* is_stable) } bool -InferenceProfiler::check_within_threshold(size_t idx, LoadStatus& load_status) +InferenceProfiler::checkWithinThreshold(size_t idx, LoadStatus& load_status) { return load_status.latencies[idx] < (latency_threshold_ms_ * 1000 * 1000); } @@ -1396,17 +1395,17 @@ InferenceProfiler::AllMPIRanksAreStable(bool current_rank_stability) #ifndef DOCTEST_CONFIG_DISABLE class TestInferenceProfiler { public: - static bool test_check_within_threshold( + static bool testCheckWithinThreshold( LoadStatus& ls, LoadParams& lp, uint64_t latency_threshold_ms) { InferenceProfiler ip; size_t idx = ls.infer_per_sec.size() - lp.stability_window; ip.latency_threshold_ms_ = latency_threshold_ms; - return ip.check_within_threshold(idx, ls); + return ip.checkWithinThreshold(idx, ls); } - static bool test_check_window_for_stability(LoadStatus& ls, LoadParams& lp) + static bool testCheckWindowForStability(LoadStatus& ls, LoadParams& lp) { size_t idx = ls.infer_per_sec.size() - lp.stability_window; @@ -1414,19 +1413,19 @@ class TestInferenceProfiler { ip.load_parameters_.stability_threshold = lp.stability_threshold; ip.load_parameters_.stability_window = lp.stability_window; - return ip.check_window_for_stability(idx, ls); + return ip.checkWindowForStability(idx, ls); }; - static bool test_determine_stability(LoadStatus& ls, LoadParams& lp) + static bool testDetermineStability(LoadStatus& ls, LoadParams& lp) { InferenceProfiler ip; ip.load_parameters_.stability_threshold = lp.stability_threshold; ip.load_parameters_.stability_window = lp.stability_window; - return ip.determine_stability(ls); + return ip.determineStability(ls); } - static bool test_is_done_profiling( + static bool testIsDoneProfiling( LoadStatus& ls, LoadParams& lp, uint64_t latency_threshold_ms) { InferenceProfiler ip; @@ -1435,8 +1434,8 @@ class TestInferenceProfiler { ip.latency_threshold_ms_ = latency_threshold_ms; ip.mpi_driver_ = std::make_shared(false); - bool is_stable = ip.determine_stability(ls); - return ip.is_done_profiling(ls, &is_stable); + bool is_stable = ip.determineStability(ls); + return ip.isDoneProfiling(ls, &is_stable); }; }; @@ -1451,9 +1450,7 @@ TEST_CASE("test_check_window_for_stability") ls.latencies = {1, 1, 1}; lp.stability_window = 3; lp.stability_threshold = 0.1; - CHECK( - TestInferenceProfiler::test_check_window_for_stability(ls, lp) == - false); + CHECK(TestInferenceProfiler::testCheckWindowForStability(ls, lp) == false); } SUBCASE("test throughput stable") { @@ -1461,8 +1458,7 @@ TEST_CASE("test_check_window_for_stability") ls.latencies = {1, 1, 1}; lp.stability_window = 3; lp.stability_threshold = 0.1; - CHECK( - TestInferenceProfiler::test_check_window_for_stability(ls, lp) == true); + CHECK(TestInferenceProfiler::testCheckWindowForStability(ls, lp) == true); } SUBCASE("test latency not stable") { @@ -1470,9 +1466,7 @@ TEST_CASE("test_check_window_for_stability") ls.latencies = {1, 100, 50}; lp.stability_window = 3; lp.stability_threshold = 0.1; - CHECK( - TestInferenceProfiler::test_check_window_for_stability(ls, lp) == - false); + CHECK(TestInferenceProfiler::testCheckWindowForStability(ls, lp) == false); } SUBCASE("test latency stable") { @@ -1480,8 +1474,7 @@ TEST_CASE("test_check_window_for_stability") ls.latencies = {45, 50, 45}; lp.stability_window = 3; lp.stability_threshold = 0.1; - CHECK( - TestInferenceProfiler::test_check_window_for_stability(ls, lp) == true); + CHECK(TestInferenceProfiler::testCheckWindowForStability(ls, lp) == true); } SUBCASE("test throughput stable after many measurements") { @@ -1489,8 +1482,7 @@ TEST_CASE("test_check_window_for_stability") ls.latencies = {1, 1, 1, 1, 1, 1, 1}; lp.stability_window = 3; lp.stability_threshold = 0.1; - CHECK( - TestInferenceProfiler::test_check_window_for_stability(ls, lp) == true); + CHECK(TestInferenceProfiler::testCheckWindowForStability(ls, lp) == true); } } @@ -1508,7 +1500,7 @@ TEST_CASE("test check within threshold") { ls.latencies = {2000000, 2000000, 2000000}; CHECK( - TestInferenceProfiler::test_check_within_threshold( + TestInferenceProfiler::testCheckWithinThreshold( ls, lp, latency_threshold_ms) == false); } @@ -1516,7 +1508,7 @@ TEST_CASE("test check within threshold") { ls.latencies = {100000, 100000, 100000}; CHECK( - TestInferenceProfiler::test_check_within_threshold( + TestInferenceProfiler::testCheckWithinThreshold( ls, lp, latency_threshold_ms) == true); } } @@ -1533,10 +1525,10 @@ TEST_CASE("test_determine_stability") lp.stability_window = 3; lp.stability_threshold = 0.1; uint64_t latency_threshold_ms = 1; - CHECK(TestInferenceProfiler::test_determine_stability(ls, lp) == false); + CHECK(TestInferenceProfiler::testDetermineStability(ls, lp) == false); ls.infer_per_sec = {500.0, 520.0, 510.0}; - CHECK(TestInferenceProfiler::test_determine_stability(ls, lp) == true); + CHECK(TestInferenceProfiler::testDetermineStability(ls, lp) == true); } } @@ -1555,7 +1547,7 @@ TEST_CASE("test_is_done_profiling") uint64_t latency_threshold_ms = NO_LIMIT; CHECK( - TestInferenceProfiler::test_is_done_profiling( + TestInferenceProfiler::testIsDoneProfiling( ls, lp, latency_threshold_ms) == false); } @@ -1568,7 +1560,7 @@ TEST_CASE("test_is_done_profiling") uint64_t latency_threshold_ms = NO_LIMIT; CHECK( - TestInferenceProfiler::test_is_done_profiling( + TestInferenceProfiler::testIsDoneProfiling( ls, lp, latency_threshold_ms) == false); } @@ -1581,7 +1573,7 @@ TEST_CASE("test_is_done_profiling") lp.stability_threshold = 0.1; uint64_t latency_threshold_ms = 1; CHECK( - TestInferenceProfiler::test_is_done_profiling( + TestInferenceProfiler::testIsDoneProfiling( ls, lp, latency_threshold_ms) == true); } @@ -1594,12 +1586,12 @@ TEST_CASE("test_is_done_profiling") uint64_t latency_threshold_ms = 1; CHECK( - TestInferenceProfiler::test_is_done_profiling( + TestInferenceProfiler::testIsDoneProfiling( ls, lp, latency_threshold_ms) == false); ls.infer_per_sec = {500.0, 520.0, 510.0}; CHECK( - TestInferenceProfiler::test_is_done_profiling( + TestInferenceProfiler::testIsDoneProfiling( ls, lp, latency_threshold_ms) == true); } } diff --git a/src/c++/perf_analyzer/inference_profiler.h b/src/c++/perf_analyzer/inference_profiler.h index e75d112d7..1cb28284b 100644 --- a/src/c++/perf_analyzer/inference_profiler.h +++ b/src/c++/perf_analyzer/inference_profiler.h @@ -333,41 +333,41 @@ class InferenceProfiler { /// A helper function to determine if profiling is stable /// \param load_status Stores the observations of infer_per_sec and latencies /// \return Returns if the threshold and latencies are stable. - bool determine_stability(LoadStatus& load_status); + bool determineStability(LoadStatus& load_status); /// Check if latency at index idx is within the latency threshold /// \param idx index in latency vector /// \param load_status Stores the observations of infer_per_sec and latencies /// \return Returns whether the latencies are below the max threshold - bool check_within_threshold(size_t idx, LoadStatus& load_status); + bool checkWithinThreshold(size_t idx, LoadStatus& load_status); /// A helper function to determine if profiling is done /// \param load_status Stores the observations of infer_per_sec and latencies /// \param is_stable Returns whether the measurement stabilized or not. /// \return Returns if we should break out of the infinite stability check /// loop. - bool is_done_profiling(LoadStatus& load_status, bool* is_stable); + bool isDoneProfiling(LoadStatus& load_status, bool* is_stable); /// Check if observed inferences and latencies are within threshold /// for a single window starting at idx /// \param idx index in latency vector /// \param load_status Stores the observations of infer_per_sec and latencies /// \return Returns whether inference and latency are stable - bool check_window_for_stability(size_t idx, LoadStatus& load_status); + bool checkWindowForStability(size_t idx, LoadStatus& load_status); /// Check if observed inferences are within threshold /// for a single window starting at idx /// \param idx index in latency vector /// \param load_status Stores the observations of infer_per_sec and latencies /// \return Returns whether inference is stable - bool is_infer_window_stable(size_t idx, LoadStatus& load_status); + bool isInferWindowStable(size_t idx, LoadStatus& load_status); /// Check if observed latencies are within threshold /// for a single window starting at idx /// \param idx index in latency vector /// \param load_status Stores the observations of infer_per_sec and latencies /// \return Returns whether latency is stable - bool is_latency_window_stable(size_t idx, LoadStatus& load_status); + bool isLatencyWindowStable(size_t idx, LoadStatus& load_status); /// Helper function to perform measurement. /// \param status_summary The summary of this measurement.