Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma GCC optimize "-O3"
- #include <iostream>
- #include <vector>
- #include <chrono>
- using namespace std;
- using namespace std::chrono;
- inline int test(const int &x) {
- return x + 1;
- }
- int main() {
- high_resolution_clock::time_point roundStart = high_resolution_clock::now();
- vector<int> vec(1000000);
- for (int i = 0; i < 1000000; ++i) {
- vec.push_back(test(i));
- }
- for (int i = 0; i < 1000000; ++i) {
- int a = vec[i];
- }
- high_resolution_clock::time_point end = high_resolution_clock::now();
- duration<double> time_span = duration_cast<duration<double>>(end - roundStart);
- cout << (time_span.count() * 1000) << "ms" << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement