All pastes #829204 Raw Edit

Someone

public text v1 · immutable
#829204 ·published 2007-12-23 00:01 UTC
rendered paste body
#include <cstdlib>
#include <time.h>
#include <iostream>
#include <vector>
#include <list>
using namespace std;

int main(int argc, char *argv[])
{

    vector<int> v;
    clock_t czas = clock(); 
     for (int i=0; i<100000; i++)
     v.insert(v.begin(), 0);
     printf("Czas %f\n", (float)(clock() - czas) / CLOCKS_PER_SEC);
     
     
     list<int> l;
     clock_t czas2 = clock(); 
     for (int i=0; i<100000; i++)
     l.insert(l.begin(), 0);
     printf("Czas %f\n", (float)(clock() - czas2) / CLOCKS_PER_SEC);
     
     clock_t czas3 = clock(); 
     for (int i=0; i<100000; i++)
     {
      int licznik = 0;
       
      for (list<int>::iterator j = l.begin();  j != l.end(); j++,licznik++)
      { 
          if (licznik ==5000) 
          {
                      printf("%d",*j); 
                      break;
          }
      
      }
      
      }
       printf("Czas %f\n", (float)(clock() - czas2) / CLOCKS_PER_SEC);
       
       clock_t czas4 = clock(); 
       for (int i=0; i<100000; i++)
       {
            printf("%d", v[5000]);
       }
       
       
      printf("Czas %f\n", (float)(clock() - czas4) / CLOCKS_PER_SEC);
    system("PAUSE");
    return EXIT_SUCCESS;
}