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.3.tar.gz
(4.0 kB
view details)
File details
Details for the file timerpp-0.3.tar.gz
.
File metadata
- Download URL: timerpp-0.3.tar.gz
- Upload date:
- Size: 4.0 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 | 255296198db1bd1fa47c87e8b2befb8c1a9e4f4045f6305bff3a10f18f347a16 |
|
MD5 | 705441e378ad7d1773c52b0d7a849306 |
|
BLAKE2b-256 | d673e67ef015f945e9468ed13020fc2472bd60d4d8972ca03e846d28c0a0427c |