173 lines
4.8 KiB
C++
173 lines
4.8 KiB
C++
#include "pip.h"
|
|
|
|
static const char * smallstr = "abcdef";
|
|
|
|
static const char * bigstr = "zsxdcgfhvbncjdbasljcvavcjadnwnxudvbabdhjlavudvdaljsvclavjlasdhvcjhldsavhjldasvfjlhsavdjhavdjhvfjhldasvfjlasvfhjldasvfhjasvfdjdasfhvjldasvhfjlasvfhjlahsvdfhjfvfvdjalsvfjlhasdvfdjsalvfhhjldasvfdjhaldsvfhjdvsfjhlavfjhlavfladlsvfjlasdvfdhjlavfhjldasvfhjlavfhjldvfhjlalsdvfjlhvasfhjlvchjlavchjladvchjldladvschjlladscvjlhdcahjchjllcahjllvcdjladsvhldbcljadsbcjdhlsachjlvdsa hjlcldajc hljdascbhaldb cldhashd l cajlhs chdsbfhlbfdasdffadsfjkbfkjldsabflhbcldhsbhclabchljadsbchldahsbcladsbhclhabhasbclasbdhl";
|
|
|
|
PIKbdListener kbd;
|
|
#include <iostream>
|
|
#include <codecvt>
|
|
|
|
int main(int argc, char * argv[]) {
|
|
auto rstr = PIString::fromUTF8("ascii русский!");
|
|
/*for (PIChar c: rstr)
|
|
std::wcout << c.toWChar();
|
|
std::wcout << std::endl;*/
|
|
piCout << PIChar::fromUTF8("│");
|
|
piCout << PICoutManipulators::Hex << (int)PIChar::fromUTF8("│").toWChar();
|
|
piCout << rstr;
|
|
|
|
/*char rs[] = "й";
|
|
piCout << PIString(PIChar::fromUTF8(rs));
|
|
std::cout << sizeof(rs) << " chars ";
|
|
for (int i = 0; i < sizeof(rs); ++i)
|
|
std::cout << "'" << (char)(rs[i]) << "' " << (int)(uchar)(rs[i]);
|
|
std::cout << std::endl;
|
|
CONNECTL(&kbd, keyPressed, ([](PIKbdListener::KeyEvent k, void*){
|
|
;
|
|
piCout << k.key << PIChar((ushort)k.key);
|
|
}));
|
|
kbd.start();
|
|
WAIT_FOR_EXIT;*/
|
|
//return 0;
|
|
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();
|
|
PIString is = PIString::fromAscii(bigstr);
|
|
tm.reset();
|
|
for(int i=0; i<cc; ++i) {
|
|
l = is.toByteArray().size();
|
|
}
|
|
piCout << l << "PIString::toByteArray" << tm.elapsed_m();
|
|
PIByteArray ba = is.toByteArray();
|
|
tm.reset();
|
|
for(int i=0; i<cc; ++i) {
|
|
PIString s = PIString::fromUTF8(ba);
|
|
l = s.size();
|
|
}
|
|
piCout << l << "PIString::fromByteArray" << tm.elapsed_m();
|
|
tm.reset();
|
|
for(int i=0; i<cc; ++i) {
|
|
PIString s = PIString::fromNumber(ba.size());
|
|
l = s.size();
|
|
}
|
|
piCout << l << "PIString::fromNumber" << tm.elapsed_m();
|
|
tm.reset();
|
|
for(int i=0; i<cc; ++i) {
|
|
PIString s = is;
|
|
l = s.size();
|
|
}
|
|
piCout << l << "PIString::assign empty" << tm.elapsed_m();
|
|
PIString is2 = PIString::fromUTF8(ba);
|
|
tm.reset();
|
|
for(int i=0; i<cc; ++i) {
|
|
PIString s = is;
|
|
l = s.size();
|
|
s = is2;
|
|
l += s.size();
|
|
}
|
|
piCout << l << "PIString::assign non empty" << tm.elapsed_m();
|
|
return 0;
|
|
}
|