Skip to content

Commit

Permalink
Capitalize method names
Browse files Browse the repository at this point in the history
  • Loading branch information
debermudez committed Jun 8, 2022
1 parent d793e20 commit c6a5b46
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 41 deletions.
70 changes: 35 additions & 35 deletions src/c++/perf_analyzer/inference_profiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -637,9 +637,9 @@ InferenceProfiler::ProfileHelper(
}
}

*is_stable = determineStability(load_status);
*is_stable = DetermineStability(load_status);

if (isDoneProfiling(load_status, is_stable)) {
if (IsDoneProfiling(load_status, is_stable)) {
break;
}

Expand All @@ -665,7 +665,7 @@ InferenceProfiler::ProfileHelper(
}

bool
InferenceProfiler::determineStability(LoadStatus& load_status)
InferenceProfiler::DetermineStability(LoadStatus& load_status)
{
bool stable = false;
if (load_status.infer_per_sec.size() >= load_parameters_.stability_window) {
Expand All @@ -679,20 +679,20 @@ InferenceProfiler::determineStability(LoadStatus& load_status)
}
}

stable = stable && checkWindowForStability(idx, load_status);
stable = stable && CheckWindowForStability(idx, load_status);
}
return stable;
}

bool
InferenceProfiler::checkWindowForStability(size_t idx, LoadStatus& load_status)
InferenceProfiler::CheckWindowForStability(size_t idx, LoadStatus& load_status)
{
return isInferWindowStable(idx, load_status) &&
isLatencyWindowStable(idx, load_status);
return IsInferWindowStable(idx, load_status) &&
IsLatencyWindowStable(idx, load_status);
}

bool
InferenceProfiler::isInferWindowStable(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(
Expand All @@ -706,7 +706,7 @@ InferenceProfiler::isInferWindowStable(size_t idx, LoadStatus& load_status)
}

bool
InferenceProfiler::isLatencyWindowStable(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(
Expand All @@ -719,15 +719,15 @@ InferenceProfiler::isLatencyWindowStable(size_t idx, LoadStatus& load_status)
}

bool
InferenceProfiler::isDoneProfiling(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;
bool within_threshold = true;
bool done = false;

for (size_t i = idx; i < load_status.infer_per_sec.size(); i++) {
within_threshold &= checkWithinThreshold(idx, load_status);
within_threshold &= CheckWithinThreshold(idx, load_status);
}

if (mpi_driver_->IsMPIRun()) {
Expand All @@ -744,7 +744,7 @@ InferenceProfiler::isDoneProfiling(LoadStatus& load_status, bool* is_stable)
}

bool
InferenceProfiler::checkWithinThreshold(size_t idx, LoadStatus& load_status)
InferenceProfiler::CheckWithinThreshold(size_t idx, LoadStatus& load_status)
{
return load_status.latencies[idx] < (latency_threshold_ms_ * 1000 * 1000);
}
Expand Down Expand Up @@ -1387,37 +1387,37 @@ class TestInferenceProfiler {
}


static bool testCheckWithinThreshold(
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.checkWithinThreshold(idx, ls);
return ip.CheckWithinThreshold(idx, ls);
}

static bool testCheckWindowForStability(LoadStatus& ls, LoadParams& lp)
static bool TestCheckWindowForStability(LoadStatus& ls, LoadParams& lp)
{
size_t idx = ls.infer_per_sec.size() - lp.stability_window;

InferenceProfiler ip;
ip.load_parameters_.stability_threshold = lp.stability_threshold;
ip.load_parameters_.stability_window = lp.stability_window;

return ip.checkWindowForStability(idx, ls);
return ip.CheckWindowForStability(idx, ls);
};

static bool testDetermineStability(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.determineStability(ls);
return ip.DetermineStability(ls);
}

static bool testIsDoneProfiling(
static bool TestIsDoneProfiling(
LoadStatus& ls, LoadParams& lp, uint64_t latency_threshold_ms)
{
InferenceProfiler ip;
Expand All @@ -1426,8 +1426,8 @@ class TestInferenceProfiler {
ip.latency_threshold_ms_ = latency_threshold_ms;
ip.mpi_driver_ = std::make_shared<triton::perfanalyzer::MPIDriver>(false);

bool is_stable = ip.determineStability(ls);
return ip.isDoneProfiling(ls, &is_stable);
bool is_stable = ip.DetermineStability(ls);
return ip.IsDoneProfiling(ls, &is_stable);
};
};

Expand Down Expand Up @@ -1491,39 +1491,39 @@ TEST_CASE("test_check_window_for_stability")
ls.latencies = {1, 1, 1};
lp.stability_window = 3;
lp.stability_threshold = 0.1;
CHECK(TestInferenceProfiler::testCheckWindowForStability(ls, lp) == false);
CHECK(TestInferenceProfiler::TestCheckWindowForStability(ls, lp) == false);
}
SUBCASE("test throughput stable")
{
ls.infer_per_sec = {500.0, 520.0, 510.0};
ls.latencies = {1, 1, 1};
lp.stability_window = 3;
lp.stability_threshold = 0.1;
CHECK(TestInferenceProfiler::testCheckWindowForStability(ls, lp) == true);
CHECK(TestInferenceProfiler::TestCheckWindowForStability(ls, lp) == true);
}
SUBCASE("test latency not stable")
{
ls.infer_per_sec = {500.0, 520.0, 510.0};
ls.latencies = {1, 100, 50};
lp.stability_window = 3;
lp.stability_threshold = 0.1;
CHECK(TestInferenceProfiler::testCheckWindowForStability(ls, lp) == false);
CHECK(TestInferenceProfiler::TestCheckWindowForStability(ls, lp) == false);
}
SUBCASE("test latency stable")
{
ls.infer_per_sec = {500.0, 520.0, 510.0};
ls.latencies = {45, 50, 45};
lp.stability_window = 3;
lp.stability_threshold = 0.1;
CHECK(TestInferenceProfiler::testCheckWindowForStability(ls, lp) == true);
CHECK(TestInferenceProfiler::TestCheckWindowForStability(ls, lp) == true);
}
SUBCASE("test throughput stable after many measurements")
{
ls.infer_per_sec = {1.0, 1000.0, 500.0, 1500.0, 500.0, 520.0, 510.0};
ls.latencies = {1, 1, 1, 1, 1, 1, 1};
lp.stability_window = 3;
lp.stability_threshold = 0.1;
CHECK(TestInferenceProfiler::testCheckWindowForStability(ls, lp) == true);
CHECK(TestInferenceProfiler::TestCheckWindowForStability(ls, lp) == true);
}
}

Expand All @@ -1541,15 +1541,15 @@ TEST_CASE("test check within threshold")
{
ls.latencies = {2000000, 2000000, 2000000};
CHECK(
TestInferenceProfiler::testCheckWithinThreshold(
TestInferenceProfiler::TestCheckWithinThreshold(
ls, lp, latency_threshold_ms) == false);
}

SUBCASE("test within threshold")
{
ls.latencies = {100000, 100000, 100000};
CHECK(
TestInferenceProfiler::testCheckWithinThreshold(
TestInferenceProfiler::TestCheckWithinThreshold(
ls, lp, latency_threshold_ms) == true);
}
}
Expand All @@ -1566,10 +1566,10 @@ TEST_CASE("test_determine_stability")
lp.stability_window = 3;
lp.stability_threshold = 0.1;
uint64_t latency_threshold_ms = 1;
CHECK(TestInferenceProfiler::testDetermineStability(ls, lp) == false);
CHECK(TestInferenceProfiler::TestDetermineStability(ls, lp) == false);

ls.infer_per_sec = {500.0, 520.0, 510.0};
CHECK(TestInferenceProfiler::testDetermineStability(ls, lp) == true);
CHECK(TestInferenceProfiler::TestDetermineStability(ls, lp) == true);
}
}

Expand All @@ -1588,7 +1588,7 @@ TEST_CASE("test_is_done_profiling")
uint64_t latency_threshold_ms = NO_LIMIT;

CHECK(
TestInferenceProfiler::testIsDoneProfiling(
TestInferenceProfiler::TestIsDoneProfiling(
ls, lp, latency_threshold_ms) == false);
}

Expand All @@ -1601,7 +1601,7 @@ TEST_CASE("test_is_done_profiling")
uint64_t latency_threshold_ms = NO_LIMIT;

CHECK(
TestInferenceProfiler::testIsDoneProfiling(
TestInferenceProfiler::TestIsDoneProfiling(
ls, lp, latency_threshold_ms) == false);
}

Expand All @@ -1614,7 +1614,7 @@ TEST_CASE("test_is_done_profiling")
lp.stability_threshold = 0.1;
uint64_t latency_threshold_ms = 1;
CHECK(
TestInferenceProfiler::testIsDoneProfiling(
TestInferenceProfiler::TestIsDoneProfiling(
ls, lp, latency_threshold_ms) == true);
}

Expand All @@ -1627,12 +1627,12 @@ TEST_CASE("test_is_done_profiling")
uint64_t latency_threshold_ms = 1;

CHECK(
TestInferenceProfiler::testIsDoneProfiling(
TestInferenceProfiler::TestIsDoneProfiling(
ls, lp, latency_threshold_ms) == false);
ls.infer_per_sec = {500.0, 520.0, 510.0};

CHECK(
TestInferenceProfiler::testIsDoneProfiling(
TestInferenceProfiler::TestIsDoneProfiling(
ls, lp, latency_threshold_ms) == true);
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/c++/perf_analyzer/inference_profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,41 +337,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 determineStability(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 checkWithinThreshold(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 isDoneProfiling(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 checkWindowForStability(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 isInferWindowStable(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 isLatencyWindowStable(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.
Expand Down

0 comments on commit c6a5b46

Please sign in to comment.