I want to test which data structure is the best by looking at the run-time performance of my algorithm, how do I do it?
For example I already have a hashmap<
First of all take a look at my reply to this question; it contains a portable (windows/linux) function to get the time in milliseconds.
Next, do something like this:
int64 start_time = GetTimeMs64();
const int NUM_TIMES = 100000; /* Choose this so it takes at the very least half a minute to run */
for (int i = 0; i < NUM_TIMES; ++i) {
/* Code you want to time.. */
}
double milliseconds = (GetTimeMs64() - start_time) / (double)NUM_TIMES;
All done! (Note that I haven't tried to compile it)