SiddiqSoft.TimeThis
2.5.0
dotnet add package SiddiqSoft.TimeThis --version 2.5.0
NuGet\Install-Package SiddiqSoft.TimeThis -Version 2.5.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SiddiqSoft.TimeThis" Version="2.5.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SiddiqSoft.TimeThis" Version="2.5.0" />
<PackageReference Include="SiddiqSoft.TimeThis" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SiddiqSoft.TimeThis --version 2.5.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SiddiqSoft.TimeThis, 2.5.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SiddiqSoft.TimeThis@2.5.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SiddiqSoft.TimeThis&version=2.5.0
#tool nuget:?package=SiddiqSoft.TimeThis&version=2.5.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
TimeThis
timethis is a lightweight, header-only Modern C++20 stopwatch utility for measuring code execution time with optional callbacks.
Documentation
Features
- RAII-Based Timing: Automatically measures elapsed time from construction to destruction.
- Optional Callbacks: Execute a function with the elapsed duration on scope exit.
std::formatSupport: Native formatter specialization forstd::format.- Source Location Tracking: Automatically captures where the timer was created via
std::source_location. - Stream Output: Direct output stream integration via
operator<<. - Header-Only C++20: No library linkage required, just include and use.
- Single Ownership: Deleted copy/move operations prevent accidental misuse.
Quick Example
Basic Timing
#include <iostream>
#include "siddiqsoft/timethis.hpp"
int main()
{
siddiqsoft::timethis timer;
// ... do work ...
std::cout << "Elapsed: " << timer.lap() << " us\n";
return 0;
}
With Callback
#include <iostream>
#include <chrono>
#include "siddiqsoft/timethis.hpp"
void process()
{
siddiqsoft::timethis timer([](const auto& duration) {
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(duration);
std::cout << "Operation took " << ms.count() << " ms\n";
});
// ... do work ...
} // Callback invoked on scope exit
With std::format
#include <iostream>
#include <format>
#include "siddiqsoft/timethis.hpp"
siddiqsoft::timethis timer;
// ... do work ...
std::cout << std::format("{}\n", timer);
Stream Output
siddiqsoft::timethis timer;
// ... do work ...
std::cout << timer << std::endl; // Outputs: <function_name> took <elapsed>ns
Installation
CMake (CPM)
include(CPM.cmake)
cpmaddpackage("gh:SiddiqSoft/TimeThis#2.5.0")
target_link_libraries(myapp PRIVATE timethis::timethis)
CMake (FetchContent)
include(FetchContent)
FetchContent_Declare(
timethis
GIT_REPOSITORY https://github.com/SiddiqSoft/TimeThis.git
GIT_TAG v2.5.0
)
FetchContent_MakeAvailable(timethis)
target_link_libraries(myapp PRIVATE timethis::timethis)
NuGet (Windows / Visual Studio)
Install-Package SiddiqSoft.TimeThis
Dependencies
graph TD
timethis["timethis::timethis"]
subgraph Test["Test Dependencies (Optional)"]
GTEST["gtest v1.17.0"]
end
timethis -. "timethis_BUILD_TESTS=ON" .-> GTEST
See dependencies.md for detailed SBOM breakdown.
License
Licensed under the BSD 3-Clause License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| native | native is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SiddiqSoft.TimeThis:
| Package | Downloads |
|---|---|
|
SiddiqSoft.CosmosClient
Azure Cosmos REST-API Client for Modern C++ |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.5.0 | 54 | 9/7/2026 |
| 2.4.1 | 480 | 5/18/2026 |
| 2.4.0 | 259 | 5/9/2026 |
| 2.3.0 | 243 | 5/6/2026 |
| 2.2.0 | 240 | 5/6/2026 |
| 2.1.3 | 653 | 1/22/2025 |
| 2.1.2 | 663 | 11/14/2024 |
| 2.1.1 | 583 | 11/8/2024 |
| 2.0.2 | 578 | 11/5/2024 |
| 2.0.1 | 565 | 11/5/2024 |
| 2.0.0 | 576 | 11/5/2024 |
| 1.3.1 | 544 | 11/5/2024 |
| 1.3.0 | 579 | 10/30/2024 |
| 1.2.1 | 543 | 10/30/2024 |
| 1.1.5 | 1,287 | 11/20/2021 |
| 1.1.4 | 897 | 7/30/2021 |
| 1.1.3 | 886 | 7/28/2021 |
| 1.1.2 | 944 | 7/28/2021 |
| 1.1.1 | 930 | 7/28/2021 |
| 1.1.0 | 9,843 | 7/28/2021 |
Loading failed
## v2.5.0 Release
For detailed release notes, visit: https://github.com/SiddiqSoft/TimeThis/releases