function::cputime_to_msecs - Linux
Overview
function::cputime_to_msecs
is a function within the google
C++ library that converts CPU time to milliseconds. It is commonly used for benchmarking performance or measuring elapsed time.
Syntax
namespace google {
namespace function {
double cputime_to_msecs() noexcept;
} // namespace function
} // namespace google
Options/Flags
This function has no options or flags.
Examples
Convert a CPU time value to milliseconds:
#include <iostream>
#include <google/function.h>
int main() {
// Get the CPU time in seconds.
clock_t start = clock();
// Do something that takes a while.
// ...
// Get the CPU time again.
clock_t end = clock();
// Convert the CPU time to milliseconds.
double elapsed_ms = google::function::cputime_to_msecs(end - start);
// Print the elapsed time.
std::cout << "Elapsed time: " << elapsed_ms << " milliseconds" << std::endl;
return 0;
}
Common Issues
None.
Integration
None.
Related Commands
clock()
: Get the CPU time in seconds.getrusage(2)
: Get information about resource usage, including CPU time.