Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/tests/test_EntityMap.h
Show All 17 Lines | |||||
#include "lib/self_test.h" | #include "lib/self_test.h" | ||||
#include "lib/timer.h" | #include "lib/timer.h" | ||||
#include "simulation2/serialization/ISerializer.h" | #include "simulation2/serialization/ISerializer.h" | ||||
#include "simulation2/serialization/IDeserializer.h" | #include "simulation2/serialization/IDeserializer.h" | ||||
#include "simulation2/system/EntityMap.h" | #include "simulation2/system/EntityMap.h" | ||||
#include <algorithm> | |||||
#include <random> | |||||
class TestEntityMap : public CxxTest::TestSuite | class TestEntityMap : public CxxTest::TestSuite | ||||
{ | { | ||||
public: | public: | ||||
void setUp() | void setUp() | ||||
{ | { | ||||
} | } | ||||
void tearDown() | void tearDown() | ||||
▲ Show 20 Lines • Show All 187 Lines • ▼ Show 20 Lines | for (int i = 1; i <= 200000; ++i) | ||||
test.erase(i); | test.erase(i); | ||||
tt = timer_Time() - t; | tt = timer_Time() - t; | ||||
printf("Erasing 200K non-existing elements: %lfs\n", tt); | printf("Erasing 200K non-existing elements: %lfs\n", tt); | ||||
// prep random vector | // prep random vector | ||||
std::vector<int> vec; | std::vector<int> vec; | ||||
for (int i = 1; i <= 200000; ++i) | for (int i = 1; i <= 200000; ++i) | ||||
vec.push_back(i); | vec.push_back(i); | ||||
std::random_shuffle(vec.begin(), vec.end()); | |||||
std::shuffle(vec.begin(), vec.end(), std::mt19937{}); | |||||
vladislavbelov: It doesn't make sense to create local variables here. | |||||
for (int i = 1; i <= 200000; ++i) | for (int i = 1; i <= 200000; ++i) | ||||
test.insert(i,i); | test.insert(i,i); | ||||
t = timer_Time(); | t = timer_Time(); | ||||
for (int i = 1; i <= 200000; ++i) | for (int i = 1; i <= 200000; ++i) | ||||
test.find(vec[i])->second = 3; | test.find(vec[i])->second = 3; | ||||
tt = timer_Time() - t; | tt = timer_Time() - t; | ||||
printf("200K random lookups in random order: %lfs\n", tt); | printf("200K random lookups in random order: %lfs\n", tt); | ||||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
It doesn't make sense to create local variables here.