-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
49 lines (40 loc) · 1.05 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <functional>
#include <map>
#include <random>
#include <chrono>
#include <cstdio>
#include <cinttypes>
#include "benchmark.h"
#include "MapSpotter.h"
#include "ArrayMap.h"
template<typename Map>
void insert(Map map)
{
int key;
Map::iterator it;
if (false)
{
do
{
key = std::rand();
it = map.find(key);
} while (it != map.end());
}
map[key] = std::rand();
}
void main()
{
std::cout << "Clock resolution:," << std::chrono::high_resolution_clock::period::den << std::endl;
MapSpotter spotter{};
printf("Reps,std::map,std::unordered_map,prealloc'd std::unordered_map,ArrayMap,prealloc'd ArrayMap\n");
for (int i = 500; i <= 500000; i++)
{
printf("%i,%"PRId64",%"PRId64",%"PRId64",%"PRId64",%"PRId64"\n", i,
spotter.spotStlMap<int, int>(i, insert),
spotter.spotStlUnorderedMap<int, int>(i, insert),
spotter.spotStlUnorderedMap_prealloc<int, int>(i, insert),
spotter.spotArrayMap<int, int>(i, insert),
spotter.spotArrayMap_prealloc<int, int>(i, insert));
}
}