diff --git a/main.cpp b/main.cpp index ca852d33..6e4dc99e 100644 --- a/main.cpp +++ b/main.cpp @@ -1,235 +1,155 @@ #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 -#include - - -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 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; + const int repeat = 1000; + const int no_repeat = 1; + const int small_cnt = 1000; + const int big_cnt = 1000000; PITimeMeasurer tm; - int l = 0; - tm.reset(); - for(int i=0; i insert..."; tm.reset(); - for(int i=0; i m1; + for (int i=0; i insert" << tm.elapsed_m(); + piCout << "map insert []..."; tm.reset(); - for(int i=0; i m1; + for (int i=0; i insert []" << tm.elapsed_m(); + piCout << "map insert rnd..."; tm.reset(); - for(int i=0; i m1; + for (int i=0; i insert rnd" << tm.elapsed_m(); + piCout << "map insert rnd []..."; tm.reset(); - for(int i=0; i m1; + for (int i=0; i insert rnd []" << tm.elapsed_m(); + + piCout << "bigmap insert..."; tm.reset(); - for(int i=0; i m1; + for (int i=0; i insert" << tm.elapsed_m(); + piCout << "bigmap insert []..."; tm.reset(); - for(int i=0; i m1; + for (int i=0; i insert []" << tm.elapsed_m(); + piCout << "bigmap insert rnd..."; tm.reset(); - for(int i=0; i m1; + for (int i=0; i insert rnd" << tm.elapsed_m(); + piCout << "bigmap insert rnd []..."; tm.reset(); - for(int i=0; i m1; + for (int i=0; i insert rnd []" << tm.elapsed_m(); + + PIStringList small_sl; + for (int i=0; i insert..."; tm.reset(); - for(int i=0; i m1; + for (int i=0; i insert" << tm.elapsed_m(); + piCout << "map insert []..."; tm.reset(); - for(int i=0; i m1; + for (int i=0; i insert []" << tm.elapsed_m(); + + piCout << "bigmap insert..."; tm.reset(); - for(int i=0; i m1; + for (int i=0; i insert" << tm.elapsed_m(); + piCout << "bigmap insert []..."; tm.reset(); - for(int i=0; i m1; + for (int i=0; i insert []" << tm.elapsed_m(); + + + PIMap m1; + for (int i=0; i interate..."; tm.reset(); - for(int i=0; i v; + v.reserve(m1.size()); + auto it = m1.makeIterator(); + while (it.next()) v << it.value(); } - piCout << l << "PIString::assign non empty" << tm.elapsed_m(); + piCout << "map interate" << tm.elapsed_m(); + + PIMap m2; + for (int i=0; i interate..."; + tm.reset(); + for (int c=0; c v; + v.reserve(m2.size()); + auto it = m2.makeIterator(); + while (it.next()) v << it.value(); + } + piCout << "map interate" << tm.elapsed_m(); return 0; }