Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <ctime>
- #include <vector>
- //#include <chrono> // for clock
- #include <thread> // for thread sleep
- using namespace std;
- using namespace std::chrono;
- using namespace std::this_thread;
- #include "stack.h"
- #include "list.h"
- int main()
- {
- int length = 1000;
- for(int y = 0; y < 3; y++){
- int randArr[length];
- for( int i = 0; i < length; i++ ){
- randArr[i] = i;
- }
- // Upg 1
- clock_t start;
- CStack theStack(length);
- start = std::clock();
- for (int i = 0; i < length; i++)
- {
- theStack.push(randArr[i]);
- }
- double duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC;
- cout << "Stack time at length: " << length << " is " << duration << endl;
- vector<long> theList; // Clist
- start = std::clock();
- for(int i = 0; i < length; i++){
- theList.push_back(randArr[i]); // change to insertFirst
- }
- duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC;
- cout << "List time at length: " << length << " is " << duration << endl;
- cout << "\n" << endl;
- length = (length == 1000) ? 1000000 : 10000000;
- }
- system("pause");
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement