{"id":25668655,"url":"https://github.com/tpadioleau/cxxtimer","last_synced_at":"2025-10-28T01:14:09.666Z","repository":{"id":225353920,"uuid":"168591772","full_name":"tpadioleau/cxxtimer","owner":"tpadioleau","description":"Easy to use timing and profiling library.","archived":false,"fork":false,"pushed_at":"2020-05-14T14:37:14.000Z","size":61,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-03-01T16:38:47.447Z","etag":null,"topics":["chrono","chronometer","cpp","library","monitoring","monitoring-tool","stopwatch","timer"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tpadioleau.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-01-31T20:30:07.000Z","updated_at":"2024-03-01T16:38:49.382Z","dependencies_parsed_at":"2024-03-01T16:51:19.480Z","dependency_job_id":null,"html_url":"https://github.com/tpadioleau/cxxtimer","commit_stats":null,"previous_names":["tpadioleau/cxxtimer"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpadioleau%2Fcxxtimer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpadioleau%2Fcxxtimer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpadioleau%2Fcxxtimer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpadioleau%2Fcxxtimer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tpadioleau","download_url":"https://codeload.github.com/tpadioleau/cxxtimer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240465018,"owners_count":19805824,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chrono","chronometer","cpp","library","monitoring","monitoring-tool","stopwatch","timer"],"created_at":"2025-02-24T10:40:18.083Z","updated_at":"2025-10-28T01:14:09.603Z","avatar_url":"https://github.com/tpadioleau.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cxxtimer: A timer for modern C++\n\n[![Build Status](https://travis-ci.org/tpadioleau/cxxtimer.svg?branch=master)](https://travis-ci.org/tpadioleau/cxxtimer)\n\nThis is a header only C++ library that offers an easy-to-use Timer class.\n\nYou just need to include the header file `cxxtimer.hpp` and that's it. You can aready instantiate `cxxtimer::Timer` objects to time your C++ programs.\n\n## Quick Start\n\nThe code below shows how to use **cxxtimer** library.\n\n```cpp\n#include \u003ccxxtimer.hpp\u003e\n#include \u003ciostream\u003e\n#include \u003cstring\u003e\n\nint main(int argc, char** argv) {\n\n    // Instantiate cxxtimer::Timer object\n    cxxtimer::Timer timer;\n\n    // Start the timer\n    timer.start();\n\n    // Wait for the users\n    std::string input_1;\n    std::cout \u003c\u003c \"Please, type something and press ENTER to continue: \";\n    std::getline(std::cin, input_1);\n\n    // Stop/pause the timer\n    timer.stop();\n\n    // Get the elapsed time\n    std::cout \u003c\u003c \"You took \" \u003c\u003c timer.count\u003cstd::chrono::seconds\u003e() \u003c\u003c \" seconds.\" \u003c\u003c std::endl;\n    std::cout \u003c\u003c \"You took \" \u003c\u003c timer.count\u003cstd::chrono::milliseconds\u003e() \u003c\u003c \" milliseconds.\" \u003c\u003c std::endl;\n    std::cout \u003c\u003c \"You took \" \u003c\u003c timer.count\u003cstd::chrono::nanoseconds\u003e() \u003c\u003c \" nanoseconds.\" \u003c\u003c std::endl;\n\n    return 0;\n}\n```\n\nThe `cxxtimer::Timer` class can be resumed after stop/pause. You just need to call `timer.start()` again. Furthermore, you can reset the timer as well. For this, you can call the method `timer.reset()`. After calling `timer.reset()`, the timer will be paused, so you have to call `timer.start()` to start to time again.\n\n\n## Constructors and Methods\n\n### Constructors\n\n```cpp\ncxxtimer::Timer(bool start = false)\n```\n\nIf the parameter `start` is set to `true`, the timer will be started just after its construction. If set to `false` or ignored, the timer won't be automatically started after construction.\n\nBesides the constructor above, the copy constructor\n\n```cpp\ncxxtimer::Timer(const Timer\u0026 other)\n```\nand the move constructor\n```cpp\nTimer(Timer\u0026\u0026 other)\n```\nare defined.\n\n### start\n\nStart/resume the timer.\n\n```cpp\nvoid cxxtimer::start()\n```\n\n### stop\n\n```cpp\nvoid cxxtimer::stop()\n```\n\nStop/pause the timer. After calling the method `stop()`, every call to `count()` will return the same value. To start timing again, you have to call `start()`.\n\n### reset\n\n```cpp\nvoid cxxtimer::reset()\n```\n\nStop the timer and reset it. After calling the method `stop()`, every call to `count()` will return zero. To start timing again, you have to call `start()`.\n\n### count\n\n```cpp\ntemplate \u003cclass duration_t = std::chrono::milliseconds\u003e\ntypename duration_t::rep count() const\n```\n\nIt returns the time elapsed so far. By default, it return the time in milliseconds. However, you can specify the precision you want. For example, to get the time in seconds, you can call `count\u003cstd::chrono::seconds\u003e()`. The following options are available:\n- `std::chrono::nanoseconds` for nanoseconds.\n- `std::chrono::microseconds` for microseconds.\n- `std::chrono::milliseconds` for milliseconds (default).\n- `std::chrono::seconds` for seconds.\n- `std::chrono::minutes` for minutes.\n- `std::chrono::hours` for hours.\n\n\n## Linking\n\nThis is a header only library.\n\n\n## Requirements\n\nThe only build requirement is a C++ compiler that supports C++11, since `cxxtimer.hpp` library depends on C++ library `chrono`. For example GCC \u003e= 5.0 or clang \u003e= 3.4.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftpadioleau%2Fcxxtimer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftpadioleau%2Fcxxtimer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftpadioleau%2Fcxxtimer/lists"}