Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <chrono>
- using namespace std;
- using namespace std::chrono;
- class Test {
- public:
- int x;
- float y;
- };
- inline float test1(int x, float y) {
- return x + y;
- }
- float test2(int x, float y) {
- return x + y;
- }
- inline float test3(Test* test) {
- return test->x + test->y;
- }
- float test4(Test* test) {
- return test->x + test->y;
- }
- inline float test5(Test test) {
- return test.x + test.y;
- }
- float test6(Test test) {
- return test.x + test.y;
- }
- float test7(Test &test) {
- return test.x + test.y;
- }
- int test8(int x) {
- int a = 52;
- float b = 798.5;
- bool c = true;
- if (x == 0) {
- return 0;
- }
- return test8(x - 1) + 1;
- }
- int main() {
- high_resolution_clock::time_point roundStart = high_resolution_clock::now();
- vector<Test*> vector1;
- vector<Test> vector2(100000);
- for (int i = 0; i < 100000; ++i) {
- vector1.push_back(new Test());
- }
- for (int i = 0; i < 100000; ++i) {
- test1(10, 50.5);
- test2(10, 50.5);
- test3(vector1[i]);
- test4(vector1[i]);
- test5(vector2[i]);
- test6(vector2[i]);
- test7(vector2[i]);
- test8(500);
- }
- 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