Created
March 24, 2019 19:47
-
-
Save cagbal/cab457390b85f20d13aa021a6b2bb3a5 to your computer and use it in GitHub Desktop.
push_back vs push_front
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> | |
| #include <string> | |
| using namespace std; | |
| int main() | |
| { | |
| // 2 Boş vektör oluşturalım | |
| vector<string> cok_buyuk_vector_arka, | |
| cok_buyuk_vector_on; | |
| // 50000 tane eleman ekleyeceğiz | |
| int N = 50000; | |
| // Arkaya 50000 elemanı ekleyelim | |
| auto basla = chrono::steady_clock::now(); | |
| for (int i = 0; i < N; i++) { | |
| cok_buyuk_vector_arka.push_back("abc"); | |
| } | |
| auto bitis = chrono::steady_clock::now(); | |
| cout << "Arkaya ekleme 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.insert(cok_buyuk_vector_on.begin(), "abc"); | |
| } | |
| bitis = chrono::steady_clock::now(); | |
| cout << "Öne ekleme 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