hoshi-lang dev
Yet another programming language
Loading...
Searching...
No Matches
datastruct.cpp
Go to the documentation of this file.
1#include <iostream>
2#include <chrono>
3
4struct Point {
5 long x, y, z;
6};
7
8int main() {
9 const int iterations = 10000000;
10 long total_sum = 0;
11
12 auto start = std::chrono::high_resolution_clock::now();
13
14 for (int i = 0; i < iterations; ++i) {
15 // Allocated on stack, zero overhead
16 Point p { (long)i, 1, 1 };
17 total_sum += p.x + p.y + p.z;
18 }
19
20 auto end = std::chrono::high_resolution_clock::now();
21 std::chrono::duration<double> diff = end - start;
22
23 std::cout << "C++ (Value Type/Stack): " << diff.count() << "s" << std::endl;
24 std::cout << "Final Sum: " << total_sum << std::endl;
25
26 return 0;
27}
int main()
Definition datastruct.cpp:8
long y
Definition datastruct.cpp:5
long z
Definition datastruct.cpp:5
long x
Definition datastruct.cpp:5