Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/user_guide/environment_variables.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ The following environment variables can be used to configure the project's runti

- ``PPC_IGNORE_TEST_TIME_LIMIT``: Specifies that test time limits are ignored. Used by ``scripts/run_tests.py`` to disable time limit enforcement.
Default: ``0``
- ``PPC_TASK_MAX_TIME``: Maximum allowed execution time in seconds for functional tests.
Default: ``1.0``
- ``PPC_PERF_MAX_TIME``: Maximum allowed execution time in seconds for performance tests.
Default: ``10.0``
5 changes: 3 additions & 2 deletions modules/performance/include/performance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,15 @@ class Perf {
}

auto time_secs = perf_results_.time_sec;
const auto max_time = ppc::util::GetPerfMaxTime();
std::stringstream perf_res_str;
if (time_secs < PerfResults::kMaxTime) {
if (time_secs < max_time) {
perf_res_str << std::fixed << std::setprecision(10) << time_secs;
std::cout << test_id << ":" << type_test_name << ":" << perf_res_str.str() << '\n';
} else {
std::stringstream err_msg;
err_msg << '\n' << "Task execute time need to be: ";
err_msg << "time < " << PerfResults::kMaxTime << " secs." << '\n';
err_msg << "time < " << max_time << " secs." << '\n';
err_msg << "Original time in secs: " << time_secs << '\n';
perf_res_str << std::fixed << std::setprecision(10) << -1.0;
std::cout << test_id << ":" << type_test_name << ":" << perf_res_str.str() << '\n';
Expand Down
6 changes: 3 additions & 3 deletions modules/task/include/task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,13 @@ class Task {
.count();
auto diff = static_cast<double>(duration) * 1e-9;

const auto max_time = ppc::util::GetTaskMaxTime();
std::stringstream err_msg;
if (diff < kMaxTestTime) {
if (diff < max_time) {
err_msg << "Test time:" << std::fixed << std::setprecision(10) << diff << '\n';
} else {
err_msg << "\nTask execute time need to be: ";
err_msg << "time < " << kMaxTestTime << " secs.\n";
err_msg << "time < " << max_time << " secs.\n";
err_msg << "Original time in secs: " << diff << '\n';
throw std::runtime_error(err_msg.str().c_str());
}
Expand Down Expand Up @@ -249,7 +250,6 @@ class Task {
StateOfTesting state_of_testing_ = kFunc;
TypeOfTask type_of_task_ = kUnknown;
StatusOfTask status_of_task_ = kEnabled;
static constexpr double kMaxTestTime = 1.0;
std::chrono::high_resolution_clock::time_point tmp_time_point_;
enum class PipelineStage : uint8_t {
kNone,
Expand Down
2 changes: 2 additions & 0 deletions modules/util/include/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ enum GTestParamIndex : uint8_t { kTaskGetter, kNameTest, kTestParams };

std::string GetAbsoluteTaskPath(const std::string& id_path, const std::string& relative_path);
int GetNumThreads();
double GetTaskMaxTime();
double GetPerfMaxTime();

template <typename T>
std::string GetNamespace() {
Expand Down
16 changes: 16 additions & 0 deletions modules/util/src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ int ppc::util::GetNumThreads() {
return 1;
}

double ppc::util::GetTaskMaxTime() {
const auto val = env::get<double>("PPC_TASK_MAX_TIME");
if (val.has_value()) {
return val.value();
}
return 1.0;
}

double ppc::util::GetPerfMaxTime() {
const auto val = env::get<double>("PPC_PERF_MAX_TIME");
if (val.has_value()) {
return val.value();
}
return 10.0;
}

// List of environment variables that signal the application is running under
// an MPI launcher. The array size must match the number of entries to avoid
// looking up empty environment variable names.
Expand Down
Loading