Created
March 24, 2019 20:32
-
-
Save cagbal/52822271dd094a43451ac30039e22f74 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <vector> | |
| #include <chrono> | |
| using namespace std; | |
| int main() | |
| { | |
| // 2 Boş vektör oluşturalım | |
| vector<pair<int, int>> cok_buyuk_vector_arka, | |
| cok_buyuk_vector_on; | |
| // 500000 tane eleman ekleyeceğiz | |
| int N = 500000; | |
| // Yerimizi ayırtalım | |
| cok_buyuk_vector_on.reserve(N); | |
| // Arkaya 50000 elemanı ekleyelim | |
| auto basla = chrono::steady_clock::now(); | |
| for (int i = 0; i < N; i++) { | |
| cok_buyuk_vector_arka.push_back(pair<int, int>(4,3)); | |
| } | |
| auto bitis = chrono::steady_clock::now(); | |
| cout << "push_back milisaniye cinsinden: "<< | |
| chrono::duration_cast<chrono::milliseconds>(bitis - basla).count() | |
| << endl; | |
| // Öne eklemeyi yapalım | |
| basla = chrono::steady_clock::now(); | |
| for (int i = 0; i < N; i++) { | |
| cok_buyuk_vector_on.emplace_back(4,3); | |
| } | |
| bitis = chrono::steady_clock::now(); | |
| cout << "push_back, reserve edilmiş, milisaniye cinsinden: "<< | |
| chrono::duration_cast<chrono::milliseconds>(bitis - basla).count() | |
| << endl; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment