Skip to content

Search topics & cppreference

Search all study topics, concept maps, and 6,587 C++ and C reference pages.

CLOCKS_PER_SEC

Expands to an expression (not necessarily a compile-time constant) of type std::clock_t equal to the number of clock ticks per second, as returned by std::clock().

NotebookLM
Defined in header <ctime>
#define CLOCKS_PER_SEC /* implementation-defined */

Expands to an expression (not necessarily a compile-time constant) of type std::clock_t equal to the number of clock ticks per second, as returned by std::clock().

Notes

POSIX defines CLOCKS_PER_SEC as 1'000'000, regardless of the actual precision of std::clock().

Example

example.cpp
#include <ctime>
#include <iostream>
#include <locale>
 
int main()
{
    const std::clock_t cps{CLOCKS_PER_SEC};
    std::cout.imbue(std::locale("en_US.utf8"));
    std::cout << cps << '\n';
}
Possible output
1,000,000

See also

returns raw processor clock time since the program is started
(function)
process running time
(typedef)
C documentation for CLOCKS_PER_SEC

Content from this page on cppreference.com, licensed under CC-BY-SA 3.0 and GFDL. Modified: restyled, site navigation removed, code windows added. Offline snapshot of 9 February 2025.