-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbenchmark.cpp
More file actions
37 lines (29 loc) · 838 Bytes
/
benchmark.cpp
File metadata and controls
37 lines (29 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
Jordan Dehmel
jdehmel@outlook.com
github.com/jorbDehmel
2023 - present
MIT licence via mit-license.org held by author
*/
// A "Hello World" benchmarker to test the speed of
// .tera interprettation against compiled C++
#include <chrono>
#include <iostream>
using namespace std;
int main(const int argc, const char *argv[])
{
int num = 100'000;
double average = 0;
for (int i = 0; i < num; i++)
{
auto start = chrono::high_resolution_clock::now();
cout << "Hello, World!\n";
auto end = chrono::high_resolution_clock::now();
int ellapsed = chrono::duration_cast<chrono::nanoseconds>(end - start).count();
average += ellapsed;
}
average /= num;
system("clear");
cout << "Average over " << num << " attempts: " << average << " nanoseconds\n";
return 0;
}