Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xorz57/stopwatch
Stopwatch written in C++11
https://github.com/xorz57/stopwatch
cpp cpp-library cpp11 cpp11-library header-only header-only-library stopwatch stopwatch-library
Last synced: 3 months ago
JSON representation
Stopwatch written in C++11
- Host: GitHub
- URL: https://github.com/xorz57/stopwatch
- Owner: xorz57
- Archived: true
- Created: 2024-01-29T09:15:54.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-03-24T10:31:22.000Z (9 months ago)
- Last Synced: 2024-03-25T10:45:06.950Z (9 months ago)
- Topics: cpp, cpp-library, cpp11, cpp11-library, header-only, header-only-library, stopwatch, stopwatch-library
- Language: C++
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# Stopwatch
[![Build](https://github.com/xorz57/Stopwatch/actions/workflows/Build.yml/badge.svg)](https://github.com/xorz57/Stopwatch/actions/workflows/Build.yml)
## Example
```cpp
#include "Stopwatch/Stopwatch.hpp"#include
#includevoid f(int duration) {
std::printf("%s\n", __func__);
std::this_thread::sleep_for(std::chrono::seconds(duration));
}int main() {
stopwatch_t stopwatch;stopwatch.start();
f(1);
stopwatch.stop();std::printf("stopwatch.total() = %lf ms\n", stopwatch.total()); // Not measured
stopwatch.start();
f(2);
stopwatch.stop();std::printf("stopwatch.total() = %lf ms\n", stopwatch.total()); // Not measured
stopwatch.start();
f(3);
stopwatch.stop();std::printf("stopwatch.total() = %lf ms\n", stopwatch.total()); // Not measured
stopwatch.restart();
f(1);
stopwatch.stop();std::printf("stopwatch.total() = %lf ms\n", stopwatch.total()); // Not measured
}
```## Output
```console
f
stopwatch.total() = 1000.089782 ms
f
stopwatch.total() = 3000.150913 ms
f
stopwatch.total() = 6000.231520 ms
f
stopwatch.total() = 1000.075934 ms
```## How to Build
#### Linux & macOS
```bash
git clone https://github.com/microsoft/vcpkg.git ~/vcpkg
~/vcpkg/bootstrap-vcpkg.shgit clone https://github.com/xorz57/Stopwatch.git
cd Stopwatch
cmake -B build -DCMAKE_BUILD_TYPE=Release -S . -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build --config Release
ctest --build-config Release
```#### Windows
```powershell
git clone https://github.com/microsoft/vcpkg.git C:/vcpkg
C:/vcpkg/bootstrap-vcpkg.bat
C:/vcpkg/vcpkg.exe integrate installgit clone https://github.com/xorz57/Stopwatch.git
cd Stopwatch
cmake -B build -DCMAKE_BUILD_TYPE=Release -S . -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build --config Release
ctest --build-config Release
```