centralized performance resources
This commit is contained in:
commit
50b15a1522
63 changed files with 328466 additions and 0 deletions
24
ocw/profiling/time_the_clock.cc
Normal file
24
ocw/profiling/time_the_clock.cc
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <print>
|
||||
|
||||
using namespace std;
|
||||
|
||||
constexpr static size_t TRIALS = 100000;
|
||||
|
||||
|
||||
int main() {
|
||||
chrono::microseconds diffs_ms{0};
|
||||
for (size_t loop_var = 1; loop_var <= TRIALS; ++loop_var) {
|
||||
auto t1 = chrono::high_resolution_clock::now();
|
||||
auto t2 = chrono::high_resolution_clock::now();
|
||||
diffs_ms += chrono::duration_cast<chrono::microseconds>(t2 - t1);
|
||||
}
|
||||
|
||||
print("measuring the clock in c++ 23 {} trials had an average time duration "
|
||||
"of: {} microseconds, or {} milliseconds",
|
||||
TRIALS, diffs_ms / TRIALS,
|
||||
chrono::duration_cast<chrono::milliseconds>(diffs_ms / TRIALS));
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue