Testing the C++ Containers - Results for insert and push_back
These 4 containers, vector, list, map, unordered_map...are important b.c. they represent some of the most commonly used data structures.  Internally they are represented as a dynamic array, double linked list, a searchable tree, and a hash.

I would like my results in seconds instead of clock ticks.  I tried casting to a double and a float after / CLOCKS_PER_SEC but lost precision.

Note I rounded my results at the bottom of the code by eye.

Thanks 

       #include "c_arclib.cpp"
        using namespace std;
        int main()
          {
        /*
        Define - Vector, List, Map, Unordered_map
        */
          vector<int> vector_int;
          list<int> list_int;
          map<int,int> map_int;
          unordered_map<int, int> unordered_map_int; 
        /*
        Define Loop and Time 
        */
          int i,j,loop1=5, loop2=4294967;
          clock_t time_start,time_end,time_diff;
        /*
        Run Timing Test
        */
          for(j=0;j<loop1;j++)
            {
            time_start=clock();
            for(i=0;i<loop2;++i)
              {
        	  unordered_map_int.insert(pair<int,int>(rand(),rand()));
        	  /*
              map_int.insert(pair<int,int>(rand(),rand()));
        	  vector_int.push_back(rand());
              list_int.push_back(rand());
        	  */
              }
            time_end=clock();
            time_diff=time_end-time_start;
            cout << time_diff << endl;
            }
        /*
        Results
        Push / Insert
        map (insert)					9500
        unorderd_map (insert)			3300
        list (push)						2600
        vector (push)					900
        */


Testing the C++ Containers - Results for insert and push_back
===

These 4 containers, vector, list, map, unordered_map...are important b.c. they represent some of the most commonly used data structures.  Internally they are represented as a dynamic array, double linked list, a searchable tree, and a hash.

I would like my results in seconds instead of clock ticks.  I tried casting to a double and a float after / CLOCKS_PER_SEC but lost precision.

Note I rounded my results at the bottom of the code by eye.

Thanks 

       #include "c_arclib.cpp"
        using namespace std;
        int main()
          {
        /*
        Define - Vector, List, Map, Unordered_map
        */
          vector<int> vector_int;
          list<int> list_int;
          map<int,int> map_int;
          unordered_map<int, int> unordered_map_int; 
        /*
        Define Loop and Time 
        */
          int i,j,loop1=5, loop2=4294967;
          clock_t time_start,time_end,time_diff;
        /*
        Run Timing Test
        */
          for(j=0;j<loop1;j++)
            {
            time_start=clock();
            for(i=0;i<loop2;++i)
              {
        	  unordered_map_int.insert(pair<int,int>(rand(),rand()));
        	  /*
              map_int.insert(pair<int,int>(rand(),rand()));
        	  vector_int.push_back(rand());
              list_int.push_back(rand());
        	  */
              }
            time_end=clock();
            time_diff=time_end-time_start;
            cout << time_diff << endl;
            }
        /*
        Results
        Push / Insert
        map (insert)					9500
        unorderd_map (insert)			3300
        list (push)						2600
        vector (push)					900
        */

