MCPcopy Create free account
hub / github.com/PlatformLab/NanoLog / mapCreate

Function mapCreate

runtime/Perf.cc:628–653  ·  view source on GitHub ↗

Measure the time to create and delete an entry in a small map.

Source from the content-addressed store, hash-verified

626// Measure the time to create and delete an entry in a small
627// map.
628double mapCreate()
629{
630 srand(0);
631
632 // Generate an array of random keys that will be used to lookup
633 // entries in the map.
634 int numKeys = 20;
635 uint64_t keys[numKeys];
636 for (int i = 0; i < numKeys; i++) {
637 keys[i] = rand();
638 }
639
640 int count = 10000;
641 uint64_t start = Cycles::rdtsc();
642 for (int i = 0; i < count; i += 5) {
643 std::map<uint64_t, uint64_t> map;
644 for (int j = 0; j < numKeys; j++) {
645 map[keys[j]] = 1000+j;
646 }
647 for (int j = 0; j < numKeys; j++) {
648 map.erase(keys[j]);
649 }
650 }
651 uint64_t stop = Cycles::rdtsc();
652 return Cycles::toSeconds(stop - start)/(count * numKeys);
653}
654
655// Measure the time to lookup a random element in a small map.
656double mapLookup()

Callers

nothing calls this directly

Calls 1

rdtscFunction · 0.85

Tested by

no test coverage detected