A beautiful timer from ufomap by Daniel Duberg, nanobind by Qingwen Zhang.
Running on macOS, Windows and Linux, with Python Version >= 3.8.
Install:
pip install dztimer
python3 -c 'import dztimer'
Quick Demo:
import dztimer
from time import sleep
timer = dztimer.Timing()
timer.start("Total")
timer[0].start("One Scan Cost")
for i in range(5):
sleep(0.05 + i * 0.01)
timer[0].stop()
for i in range(5):
timer[1].start("Second Scan Cost")
sleep(0.08 + i * 0.01)
print("latest one cost:",timer[1].lastSeconds())
timer[1].stop()
timer.print(random_colors=True, bold=True)
git clone https://github.com/KTH-RPL/dztimer
cd dztimer
pip install .
python3 -c 'import dztimer'
- multiple platform support, especially for windows, there is an error: error C2668: 'fpclassify': ambiguous call to overloaded function,https://stackoverflow.com/questions/61646166/how-to-resolve-fpclassify-ambiguous-call-to-overloaded-function. It's turn out if you want to
std::isnan()
in windows, you need to include<cmath>
andstd::isnan(static_cast<double> (you_value))
. - If you use
std::array
except linux, you need to include#include <array>
andstd::array<int, 2> my_array;
instead ofstd::array my_array;