236 lines
6.6 KiB
C++
236 lines
6.6 KiB
C++
#include "pip.h"
|
|
|
|
static const char * smallstr = "abcdef";
|
|
|
|
static const char * bigstr = "zsxdcgfhvbncjdbasljcvavcjadnwnxudvbabdhjlavudvdaljsvclavjlasdhvcjhldsavhjldasvfjlhsavdjhavdjhvfjhldasvfjlasvfhjldasvfhjasvfdjdasfhvjldasvhfjlasvfhjlahsvdfhjfvfvdjalsvfjlhasdvfdjsalvfhhjldasvfdjhaldsvfhjdvsfjhlavfjhlavfladlsvfjlasdvfdhjlavfhjldasvfhjlavfhjldvfhjlalsdvfjlhvasfhjlvchjlavchjladvchjldladvschjlladscvjlhdcahjchjllcahjllvcdjladsvhldbcljadsbcjdhlsachjlvdsa hjlcldajc hljdascbhaldb cldhashd l cajlhs chdsbfhlbfdasdffadsfjkbfkjldsabflhbcldhsbhclabchljadsbchldahsbcladsbhclhabhasbclasbdhl";
|
|
|
|
PIKbdListener kbd(0, 0, false);
|
|
#include <iostream>
|
|
#include <codecvt>
|
|
|
|
|
|
using namespace PICoutManipulators;
|
|
|
|
int main(int argc, char * argv[]) {
|
|
/*PIVariant vi;
|
|
piCout << vi;
|
|
vi = 1;
|
|
piCout << vi << vi.toString();
|
|
vi = "string";
|
|
piCout << vi << vi.toStringList();
|
|
vi = PIStringList("2");
|
|
piCout << vi << vi.toInt();*/
|
|
|
|
/*auto cmp = [](const PIConstChars & c0, const PIConstChars & c1){
|
|
PICout(DefaultControls) << c0 << "==" << c1 << "->" << (c0 != c1);
|
|
};
|
|
PIConstChars s;
|
|
PICout(DefaultControls | AddQuotes) << s;
|
|
s = PIConstChars("str", 2);
|
|
PICout(DefaultControls | AddQuotes) << s;
|
|
cmp(PIConstChars(), PIConstChars());
|
|
cmp(PIConstChars("str"), PIConstChars());
|
|
cmp(PIConstChars(), PIConstChars("s_tr"));
|
|
cmp(PIConstChars("str1"), PIConstChars("str"));
|
|
cmp(PIConstChars("str"), PIConstChars("str2"));
|
|
cmp(PIConstChars("str"), PIConstChars("sTr"));
|
|
cmp(PIConstChars("str"), PIConstChars("str"));
|
|
cmp(PIConstChars("1a"), PIConstChars("1b"));
|
|
cmp(PIConstChars("1c"), PIConstChars("1b"));*/
|
|
|
|
/*PIMap<PIConstChars, int> map;
|
|
map[PIConstChars()] = 0;
|
|
map[PIConstChars()] = -1;
|
|
map["_2"] = 22;
|
|
map["1"] = 11;
|
|
map["__3"] = 33;
|
|
map["10"] = 10;
|
|
map[""] = 999;
|
|
piCout << map;
|
|
|
|
piCout << PIConstChars().toString();
|
|
piCout << PIConstChars("").toString();
|
|
piCout << PIConstChars("str").toString();
|
|
PIConstChars s = " 1 2 \t";
|
|
piCout << "trim:";
|
|
PICout(DefaultControls | AddQuotes) << s.trimmed();
|
|
PICout(DefaultControls | AddQuotes) << s;
|
|
PICout(DefaultControls | AddQuotes) << s.isEmpty();*/
|
|
|
|
/*piCout << PIIODevice::availablePrefixes();
|
|
auto * d = PIIODevice::createFromFullPath("ser://COM1");
|
|
piCout << "";
|
|
piCout << d;
|
|
d->dump();
|
|
d = PIIODevice::createFromFullPath("eth://udp:127.0.0.1:5000");
|
|
piCout << "";
|
|
piCout << d;
|
|
d->dump();*/
|
|
|
|
piCout << "";
|
|
dumpApplication();
|
|
|
|
return 0;
|
|
|
|
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;
|
|
}
|