timer class
Project description
timerpp
features
- header only
- tested
- no dependencies
- python bindings
pip3 install git+https://github.com/nbdy/timerpp
pip3 install timerpp
example
cpp
#include "timerpp.h"
#include <iostream>
int main() {
uint64_t lastTimestamp = TIMESTAMP_MS;
uint64_t newTimestamp = 0;
uint32_t x = 0;
timerpp::Timer t([&x, &newTimestamp, &lastTimestamp]{
newTimestamp = TIMESTAMP_MS;
x += newTimestamp - lastTimestamp;
lastTimestamp = newTimestamp;
});
t.start(500);
std::this_thread::sleep_for(Milliseconds(1501));
t.stop();
std::cout << "1500 == " << x << std::endl;
return 0;
}
python
from timerpp import Timer
from time import sleep
class Example(Timer):
elapsed_ms = 0
def __init__(self):
Timer.__init__(self, self.callback, 500)
def callback(self):
self.elapsed_ms += 500
e = Example()
e.start()
sleep(1.49)
e.stop()
print(f"elapsed_ms: {e.elapsed_ms}")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
timerpp-0.2.tar.gz
(2.9 kB
view details)
File details
Details for the file timerpp-0.2.tar.gz
.
File metadata
- Download URL: timerpp-0.2.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bdfd6d5be27467b6090213de98cd1a516f4814c2d8cd98eb96ca49579ae5f816 |
|
MD5 | 3bd98621b0349420b1b0f584680850d7 |
|
BLAKE2b-256 | c38f69c3e7321c091db6cfba4645b148389798ac99c4c6170ada29ab3f37927f |