115 lines
3.2 KiB
C++
115 lines
3.2 KiB
C++
#include "pip.h"
|
|
|
|
static const char * smallstr = "abcdef";
|
|
|
|
static const char * bigstr = "zsxdcgfhvbncjdbasljcvavcjadnwnxudvbabdhjlavudvdaljsvclavjlasdhvcjhldsavhjldasvfjlhsavdjhavdjhvfjhldasvfjlasvfhjldasvfhjasvfdjdasfhvjldasvhfjlasvfhjlahsvdfhjfvfvdjalsvfjlhasdvfdjsalvfhhjldasvfdjhaldsvfhjdvsfjhlavfjhlavfladlsvfjlasdvfdhjlavfhjldasvfhjlavfhjldvfhjlalsdvfjlhvasfhjlvchjlavchjladvchjldladvschjlladscvjlhdcahjchjllcahjllvcdjladsvhldbcljadsbcjdhlsachjlvdsa hjlcldajc hljdascbhaldb cldhashd l cajlhs chdsbfhlbfdasdffadsfjkbfkjldsabflhbcldhsbhclabchljadsbchldahsbcladsbhclhabhasbclasbdhl";
|
|
|
|
|
|
int main(int argc, char * argv[]) {
|
|
static const int cc = 1000000;
|
|
PITimeMeasurer tm;
|
|
int l = 0;
|
|
tm.reset();
|
|
for(int i=0; i<cc; ++i) {
|
|
PIString s(smallstr);
|
|
l = s.size();
|
|
}
|
|
piCout << l << "PIString()" << tm.elapsed_m();
|
|
tm.reset();
|
|
for(int i=0; i<cc; ++i) {
|
|
PIString s = smallstr;
|
|
l = s.size();
|
|
}
|
|
piCout << l << "PIString =" << tm.elapsed_m();
|
|
tm.reset();
|
|
for(int i=0; i<cc; ++i) {
|
|
PIString s = PIStringAscii(smallstr);
|
|
l = s.size();
|
|
}
|
|
piCout << l << "PIStringAscii" << tm.elapsed_m();
|
|
tm.reset();
|
|
for(int i=0; i<cc; ++i) {
|
|
PIString s;
|
|
s += smallstr;
|
|
s += "1";
|
|
l = s.size();
|
|
}
|
|
piCout << l << "PIString + PIString" << tm.elapsed_m();
|
|
tm.reset();
|
|
for(int i=0; i<cc; ++i) {
|
|
PIString s = PIStringAscii(smallstr) + "1";
|
|
l = s.size();
|
|
}
|
|
piCout << l << "PIStringAscii + PIString" << tm.elapsed_m();
|
|
tm.reset();
|
|
for(int i=0; i<cc; ++i) {
|
|
PIString s = PIString::fromUTF8(smallstr);
|
|
l = s.size();
|
|
}
|
|
piCout << l << "PIString::fromUTF8" << tm.elapsed_m();
|
|
tm.reset();
|
|
for(int i=0; i<cc; ++i) {
|
|
PIString s = PIString::fromSystem(smallstr);
|
|
l = s.size();
|
|
}
|
|
piCout << l << "PIString::fromSystem" << tm.elapsed_m();
|
|
tm.reset();
|
|
for(int i=0; i<cc; ++i) {
|
|
PIString s = PIString::fromAscii(smallstr);
|
|
l = s.size();
|
|
}
|
|
piCout << l << "PIString::fromAscii" << tm.elapsed_m();
|
|
|
|
tm.reset();
|
|
for(int i=0; i<cc; ++i) {
|
|
PIString s(bigstr);
|
|
l = s.size();
|
|
}
|
|
piCout << l << "PIString()" << tm.elapsed_m();
|
|
tm.reset();
|
|
for(int i=0; i<cc; ++i) {
|
|
PIString s = bigstr;
|
|
l = s.size();
|
|
}
|
|
piCout << l << "PIString =" << tm.elapsed_m();
|
|
tm.reset();
|
|
for(int i=0; i<cc; ++i) {
|
|
PIString s = PIStringAscii(bigstr);
|
|
l = s.size();
|
|
}
|
|
piCout << l << "PIStringAscii" << tm.elapsed_m();
|
|
tm.reset();
|
|
for(int i=0; i<cc; ++i) {
|
|
PIString s;
|
|
s += bigstr;
|
|
s += "1";
|
|
l = s.size();
|
|
}
|
|
piCout << l << "PIString + PIString" << tm.elapsed_m();
|
|
tm.reset();
|
|
for(int i=0; i<cc; ++i) {
|
|
PIString s = PIStringAscii(bigstr) + "1";
|
|
l = s.size();
|
|
}
|
|
piCout << l << "PIStringAscii + PIString" << tm.elapsed_m();
|
|
tm.reset();
|
|
for(int i=0; i<cc; ++i) {
|
|
PIString s = PIString::fromUTF8(bigstr);
|
|
l = s.size();
|
|
}
|
|
piCout << l << "PIString::fromUTF8" << tm.elapsed_m();
|
|
tm.reset();
|
|
for(int i=0; i<cc; ++i) {
|
|
PIString s = PIString::fromSystem(bigstr);
|
|
l = s.size();
|
|
}
|
|
piCout << l << "PIString::fromSystem" << tm.elapsed_m();
|
|
tm.reset();
|
|
for(int i=0; i<cc; ++i) {
|
|
PIString s = PIString::fromAscii(bigstr);
|
|
l = s.size();
|
|
}
|
|
piCout << l << "PIString::fromAscii" << tm.elapsed_m();
|
|
return 0;
|
|
}
|