user656925
user656925

Reputation:

Test structure for Containers

I want to build a test structure to test arrays, vectors, lists, maps, and unordered_maps. Basically I want to populate each structure with a large amount of random data. I want to run 3 tests on these. I want to be able to see the Big O trends for insert and search.

Question is should I store the random data set in .txt files or pump the data directly into the containers?

I'm thinking I'll save it to disk so I can visualize what it looks like but I am wondering what type of file sizes will break the containers...is it feasible to do this?

Because the time functions are not precise the larger the data set the easier it will be to get average insert and search times.

  1. populate until break
  2. calculate insert times
  3. calculate search times

Upvotes: 2

Views: 125

Answers (1)

Nick
Nick

Reputation: 146

The text file versus generating the data in the code is really up to you...

As far as STL limitations you can use vector::max_size which would also give you a good benchmark for arrays since vectors are dynamic arrays. This function also exists for lists and maps.

The key here is whether or not you intend to also measure the time it takes to dynamically grow in size as you insert. If you just declare a vector and start inserting, I believe it will double every time you hit the current allocation limit. Alternatively you could set the current allocation to the size of your pre-defined data set with vector::reserve.

Upvotes: 2

Related Questions