156 lines
4.0 KiB
C++
156 lines
4.0 KiB
C++
#include "pip.h"
|
|
|
|
|
|
int main(int argc, char * argv[]) {
|
|
const int repeat = 1000;
|
|
const int no_repeat = 1;
|
|
const int small_cnt = 1000;
|
|
const int big_cnt = 1000000;
|
|
PITimeMeasurer tm;
|
|
|
|
|
|
piCout << "map<int, int> insert...";
|
|
tm.reset();
|
|
for (int c=0; c<repeat; ++c) {
|
|
PIMap<int, int> m1;
|
|
for (int i=0; i<small_cnt; ++i) {
|
|
m1.insert(i, i);
|
|
}
|
|
}
|
|
piCout << "map<int, int> insert" << tm.elapsed_m();
|
|
piCout << "map<int, int> insert []...";
|
|
tm.reset();
|
|
for (int c=0; c<repeat; ++c) {
|
|
PIMap<int, int> m1;
|
|
for (int i=0; i<small_cnt; ++i) {
|
|
m1[i] = i;
|
|
}
|
|
}
|
|
piCout << "map<int, int> insert []" << tm.elapsed_m();
|
|
piCout << "map<int, int> insert rnd...";
|
|
tm.reset();
|
|
for (int c=0; c<repeat; ++c) {
|
|
PIMap<int, int> m1;
|
|
for (int i=0; i<small_cnt; ++i) {
|
|
m1.insert(randomi(), i);
|
|
}
|
|
}
|
|
piCout << "map<int, int> insert rnd" << tm.elapsed_m();
|
|
piCout << "map<int, int> insert rnd []...";
|
|
tm.reset();
|
|
for (int c=0; c<repeat; ++c) {
|
|
PIMap<int, int> m1;
|
|
for (int i=0; i<small_cnt; ++i) {
|
|
m1[randomi()] = i;
|
|
}
|
|
}
|
|
piCout << "map<int, int> insert rnd []" << tm.elapsed_m();
|
|
|
|
piCout << "bigmap<int, int> insert...";
|
|
tm.reset();
|
|
for (int c=0; c<no_repeat; ++c) {
|
|
PIMap<int, int> m1;
|
|
for (int i=0; i<big_cnt; ++i) {
|
|
m1.insert(i, i);
|
|
}
|
|
}
|
|
piCout << "bigmap<int, int> insert" << tm.elapsed_m();
|
|
piCout << "bigmap<int, int> insert []...";
|
|
tm.reset();
|
|
for (int c=0; c<no_repeat; ++c) {
|
|
PIMap<int, int> m1;
|
|
for (int i=0; i<big_cnt; ++i) {
|
|
m1[i] = i;
|
|
}
|
|
}
|
|
piCout << "bigmap<int, int> insert []" << tm.elapsed_m();
|
|
piCout << "bigmap<int, int> insert rnd...";
|
|
tm.reset();
|
|
for (int c=0; c<no_repeat; ++c) {
|
|
PIMap<int, int> m1;
|
|
for (int i=0; i<big_cnt; ++i) {
|
|
m1.insert(randomi(), i);
|
|
}
|
|
}
|
|
piCout << "bigmap<int, int> insert rnd" << tm.elapsed_m();
|
|
piCout << "bigmap<int, int> insert rnd []...";
|
|
tm.reset();
|
|
for (int c=0; c<no_repeat; ++c) {
|
|
PIMap<int, int> m1;
|
|
for (int i=0; i<big_cnt; ++i) {
|
|
m1[randomi()] = i;
|
|
}
|
|
}
|
|
piCout << "bigmap<int, int> insert rnd []" << tm.elapsed_m();
|
|
|
|
PIStringList small_sl;
|
|
for (int i=0; i<small_cnt; ++i) small_sl << PIString::fromNumber(randomd());
|
|
PIStringList big_sl;
|
|
for (int i=0; i<big_cnt; ++i) big_sl << PIString::fromNumber(randomd());
|
|
piCout << "map<PIString, int> insert...";
|
|
tm.reset();
|
|
for (int c=0; c<repeat; ++c) {
|
|
PIMap<PIString, int> m1;
|
|
for (int i=0; i<small_cnt; ++i) {
|
|
m1.insert(small_sl[i], i);
|
|
}
|
|
}
|
|
piCout << "map<PIString, int> insert" << tm.elapsed_m();
|
|
piCout << "map<PIString, int> insert []...";
|
|
tm.reset();
|
|
for (int c=0; c<repeat; ++c) {
|
|
PIMap<PIString, int> m1;
|
|
for (int i=0; i<small_cnt; ++i) {
|
|
m1[small_sl[i]] = i;
|
|
}
|
|
}
|
|
piCout << "map<PIString, int> insert []" << tm.elapsed_m();
|
|
|
|
piCout << "bigmap<PIString, int> insert...";
|
|
tm.reset();
|
|
for (int c=0; c<no_repeat; ++c) {
|
|
PIMap<PIString, int> m1;
|
|
for (int i=0; i<big_cnt; ++i) {
|
|
m1.insert(big_sl[i], i);
|
|
}
|
|
}
|
|
piCout << "bigmap<PIString, int> insert" << tm.elapsed_m();
|
|
piCout << "bigmap<PIString, int> insert []...";
|
|
tm.reset();
|
|
for (int c=0; c<no_repeat; ++c) {
|
|
PIMap<PIString, int> m1;
|
|
for (int i=0; i<big_cnt; ++i) {
|
|
m1[big_sl[i]] = i;
|
|
}
|
|
}
|
|
piCout << "bigmap<PIString, int> insert []" << tm.elapsed_m();
|
|
|
|
|
|
PIMap<int, int> m1;
|
|
for (int i=0; i<big_cnt; ++i) m1.insert(i,i);
|
|
piCout << "map<int, int> interate...";
|
|
tm.reset();
|
|
for (int c=0; c<repeat; ++c) {
|
|
PIVector<int> v;
|
|
v.reserve(m1.size());
|
|
auto it = m1.makeIterator();
|
|
while (it.next()) v << it.value();
|
|
}
|
|
piCout << "map<int, int> interate" << tm.elapsed_m();
|
|
|
|
PIMap<PIString, int> m2;
|
|
for (int i=0; i<big_cnt; ++i) {
|
|
m2.insert(big_sl[i], i);
|
|
}
|
|
piCout << "map<PIString, int> interate...";
|
|
tm.reset();
|
|
for (int c=0; c<repeat; ++c) {
|
|
PIVector<int> v;
|
|
v.reserve(m2.size());
|
|
auto it = m2.makeIterator();
|
|
while (it.next()) v << it.value();
|
|
}
|
|
piCout << "map<PIString, int> interate" << tm.elapsed_m();
|
|
return 0;
|
|
}
|