pip_test clear
This commit is contained in:
352
main.cpp
352
main.cpp
@@ -117,193 +117,193 @@ struct A {
|
|||||||
|
|
||||||
//PIKbdListener kbd(0, 0, false);
|
//PIKbdListener kbd(0, 0, false);
|
||||||
|
|
||||||
void swap(int & x, int & y) {int t = x; x = y; y = t;}
|
// void swap(int & x, int & y) {int t = x; x = y; y = t;}
|
||||||
void swap2(int & x, int & y) {int t(std::move(x)); x = y; y = t;}
|
// void swap2(int & x, int & y) {int t(std::move(x)); x = y; y = t;}
|
||||||
void swap(uint & x, uint & y) {uint t = x; x = y; y = t;}
|
// void swap(uint & x, uint & y) {uint t = x; x = y; y = t;}
|
||||||
void swap2(uint & x, uint & y) {uint t(std::move(x)); x = y; y = t;}
|
// void swap2(uint & x, uint & y) {uint t(std::move(x)); x = y; y = t;}
|
||||||
void swap(ullong & x, ullong & y) {ullong t = x; x = y; y = t;}
|
// void swap(ullong & x, ullong & y) {ullong t = x; x = y; y = t;}
|
||||||
void swap2(ullong & x, ullong & y) {ullong t{std::move(x)}; x = y; y = t;}
|
// void swap2(ullong & x, ullong & y) {ullong t{std::move(x)}; x = y; y = t;}
|
||||||
void swap(llong & x, llong & y) {llong t = x; x = y; y = t;}
|
// void swap(llong & x, llong & y) {llong t = x; x = y; y = t;}
|
||||||
void swap2(llong & x, llong & y) {llong t{std::move(x)}; x = y; y = t;}
|
// void swap2(llong & x, llong & y) {llong t{std::move(x)}; x = y; y = t;}
|
||||||
void swap(double & x, double & y) {double t = x; x = y; y = t;}
|
// void swap(double & x, double & y) {double t = x; x = y; y = t;}
|
||||||
void swap2(double & x, double & y) {double t(std::move(x)); x = std::move(y); y = std::move(t);}
|
// void swap2(double & x, double & y) {double t(std::move(x)); x = std::move(y); y = std::move(t);}
|
||||||
void swap(float & x, float & y) {float t = x; x = y; y = t;}
|
// void swap(float & x, float & y) {float t = x; x = y; y = t;}
|
||||||
void swap2(float & x, float & y) {float t(std::move(x)); x = std::move(y); y = std::move(t);}
|
// void swap2(float & x, float & y) {float t(std::move(x)); x = std::move(y); y = std::move(t);}
|
||||||
void swap(PIString & x, PIString & y) {PIString t = x; x = y; y = t;}
|
// void swap(PIString & x, PIString & y) {PIString t = x; x = y; y = t;}
|
||||||
void swap2(PIString & x, PIString & y) {PIString t(std::move(x)); x = std::move(y); y = std::move(t);}
|
// void swap2(PIString & x, PIString & y) {PIString t(std::move(x)); x = std::move(y); y = std::move(t);}
|
||||||
void swap(std::string & x, std::string & y) {std::string t = x; x = y; y = t;}
|
// void swap(std::string & x, std::string & y) {std::string t = x; x = y; y = t;}
|
||||||
void swap2(std::string & x, std::string & y) {std::string t{std::move(x)}; x = std::move(y); y = std::move(t);}
|
// void swap2(std::string & x, std::string & y) {std::string t{std::move(x)}; x = std::move(y); y = std::move(t);}
|
||||||
void swap(A & x, A & y) {A t = x; x = y; y = t;}
|
// void swap(A & x, A & y) {A t = x; x = y; y = t;}
|
||||||
void swap2(A & x, A & y) {A t{std::move(x)}; x = std::move(y); y = std::move(t);}
|
// void swap2(A & x, A & y) {A t{std::move(x)}; x = std::move(y); y = std::move(t);}
|
||||||
//void swap(PIObject & x, PIObject & y) {A t = x; x = y; y = t;}
|
//void swap(PIObject & x, PIObject & y) {A t = x; x = y; y = t;}
|
||||||
//void swap2(PIObject & x, PIObject & y) {A t(std::move(x)); x = std::move(y); y = std::move(t);}
|
//void swap2(PIObject & x, PIObject & y) {A t(std::move(x)); x = std::move(y); y = std::move(t);}
|
||||||
|
|
||||||
int main(int argc, char * argv[]) {
|
int main(int argc, char * argv[]) {
|
||||||
PITimeMeasurer tm;
|
// PITimeMeasurer tm;
|
||||||
int m = 100000;
|
// int m = 100000;
|
||||||
int a = 99, b = 77;
|
// int a = 99, b = 77;
|
||||||
piCout << "int";
|
// piCout << "int";
|
||||||
tm.reset();
|
// tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
swap(a,b);
|
// swap(a,b);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
swap2(a,b);
|
// swap2(a,b);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
piSwapBinary(a,b);
|
// piSwapBinary(a,b);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
piSwap(a,b);
|
// piSwap(a,b);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s();
|
// piCout << tm.elapsed_s();
|
||||||
|
|
||||||
piCout << "size_t";
|
// piCout << "size_t";
|
||||||
size_t ta = 99, tb = 77;
|
// size_t ta = 99, tb = 77;
|
||||||
tm.reset();
|
// tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
swap(ta,tb);
|
// swap(ta,tb);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
swap2(ta,tb);
|
// swap2(ta,tb);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
piSwapBinary(ta,tb);
|
// piSwapBinary(ta,tb);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
piSwap(ta,tb);
|
// piSwap(ta,tb);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s();
|
// piCout << tm.elapsed_s();
|
||||||
|
|
||||||
piCout << "ullong";
|
// piCout << "ullong";
|
||||||
ullong lla = 99, llb = 77;
|
// ullong lla = 99, llb = 77;
|
||||||
tm.reset();
|
// tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
swap(lla,llb);
|
// swap(lla,llb);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
swap2(lla,llb);
|
// swap2(lla,llb);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
piSwapBinary(lla,llb);
|
// piSwapBinary(lla,llb);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
piSwap(lla,llb);
|
// piSwap(lla,llb);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s();
|
// piCout << tm.elapsed_s();
|
||||||
|
|
||||||
piCout << "double";
|
// piCout << "double";
|
||||||
double da = 0.99,db = 77.77;
|
// double da = 0.99,db = 77.77;
|
||||||
tm.reset();
|
// tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
swap(da,db);
|
// swap(da,db);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
swap2(da,db);
|
// swap2(da,db);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
piSwapBinary(da,db);
|
// piSwapBinary(da,db);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
piSwap(da,db);
|
// piSwap(da,db);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s();
|
// piCout << tm.elapsed_s();
|
||||||
|
|
||||||
piCout << "float";
|
// piCout << "float";
|
||||||
float fa = 0.99,fb = 77.77;
|
// float fa = 0.99,fb = 77.77;
|
||||||
tm.reset();
|
// tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
swap(fa,fb);
|
// swap(fa,fb);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
swap2(fa,fb);
|
// swap2(fa,fb);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
piSwapBinary(fa,fb);
|
// piSwapBinary(fa,fb);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
piSwap(fa,fb);
|
// piSwap(fa,fb);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s();
|
// piCout << tm.elapsed_s();
|
||||||
|
|
||||||
piCout << "A";
|
// piCout << "A";
|
||||||
A aa,ab;
|
// A aa,ab;
|
||||||
tm.reset();
|
// tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
swap(aa,ab);
|
// swap(aa,ab);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
swap2(aa,ab);
|
// swap2(aa,ab);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
piSwapBinary(aa,ab);
|
// piSwapBinary(aa,ab);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
piSwap(aa,ab);
|
// piSwap(aa,ab);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s();
|
// piCout << tm.elapsed_s();
|
||||||
|
|
||||||
piCout << "std::string";
|
// piCout << "std::string";
|
||||||
std::string ia = "123456789012345678901vfsdvsd2345678",ib = "qwertyvsdfvvsdvfsuiopqwertyuikolsdfghjklsdfghjk";
|
// std::string ia = "123456789012345678901vfsdvsd2345678",ib = "qwertyvsdfvvsdvfsuiopqwertyuikolsdfghjklsdfghjk";
|
||||||
tm.reset();
|
// tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
swap(ia,ib);
|
// swap(ia,ib);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
swap2(ia,ib);
|
// swap2(ia,ib);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
ia.swap(ib);
|
// ia.swap(ib);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
piSwap(ia,ib);
|
// piSwap(ia,ib);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s();
|
// piCout << tm.elapsed_s();
|
||||||
|
|
||||||
|
|
||||||
PIString sa = "123456789012345678901vfsdvsd2345678",sb = "qwertyvsdfvvsdvfsuiopqwertyuikolsdfghjklsdfghjk";
|
// PIString sa = "123456789012345678901vfsdvsd2345678",sb = "qwertyvsdfvvsdvfsuiopqwertyuikolsdfghjklsdfghjk";
|
||||||
piCout << "PIString";
|
// piCout << "PIString";
|
||||||
tm.reset();
|
// tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
swap(sa,sb);
|
// swap(sa,sb);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
swap2(sa, sb);
|
// swap2(sa, sb);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
sa.swap(sb);
|
// sa.swap(sb);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
piSwapBinary(sa, sb);
|
// piSwapBinary(sa, sb);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s(); tm.reset();
|
// piCout << tm.elapsed_s(); tm.reset();
|
||||||
for (int i = 0; i < m; ++i) {
|
// for (int i = 0; i < m; ++i) {
|
||||||
piSwap(sa, sb);
|
// piSwap(sa, sb);
|
||||||
}
|
// }
|
||||||
piCout << tm.elapsed_s();
|
// piCout << tm.elapsed_s();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user