Skip to content
Snippets Groups Projects
Commit 5996a526 authored by Chiara Salvoni's avatar Chiara Salvoni
Browse files

AST-1282 add python bindings for showTimings()

parent 0fb26089
Branches
Tags
1 merge request!1042AST-1282 add python bindings for showTimings()
......@@ -85,6 +85,7 @@ void register_vector(py::module &m, const char *name) {
class PublicStep : public Step {
public:
using Step::info;
using Step::showTimings;
using Step::updateInfo;
};
......@@ -122,6 +123,16 @@ PYBIND11_MODULE(pydp3, m) {
"redirected to DP3's output stream. Overrides of show() should use "
"print() "
"to output a summary of the step.")
.def(
"show_timings",
[](const dp3::steps::Step &step, double elapsed_time) {
std::stringstream ss;
step.showTimings(ss, elapsed_time);
return ss.str();
},
"Show the processing time of current step. Also provides the "
"percentage of time the current step took compared to the total "
"elapsed time given as input (in seconds).")
.def("__str__",
[](const dp3::steps::Step &step) {
std::stringstream ss;
......
......@@ -13,6 +13,7 @@ Script can be invoked in two ways:
import pytest
import os
import sys
import time
# Append current directory to system path in order to import testconfig
sys.path.append(".")
......@@ -72,6 +73,19 @@ def test_make_main_steps(tmp_path):
step.show()
step = step.get_next_step()
start_time = time.time()
while first_step.process(dp3.DPBuffer()):
print(".")
first_step.finish()
end_time = time.time()
elapsed_time = end_time - start_time
# Assert that the "show_timings" function returns the expected results.
msreader = first_step
averager = first_step.get_next_step()
mswriter = averager.get_next_step()
assert "ms) MSReader" in msreader.show_timings(elapsed_time)
assert "ms) Averager" in averager.show_timings(elapsed_time)
assert "ms) MSWriter" in mswriter.show_timings(elapsed_time)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment