git-svn-id: svn://db.shs.com.ru/pip@859 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2019-10-11 09:55:45 +00:00
parent b313a9c9f2
commit 604095672f
2 changed files with 26 additions and 14 deletions

View File

@@ -318,6 +318,19 @@ inline PICout operator <<(PICout s, const PIHash<Key, Type> & v) {
int main() {
PIConnection con;
PIString _str = "[connection]\ndevice.d = ser://COM2:9600\n";
con.configureFromString(&_str);
con.start();
PISerial * s = con.deviceByName("d")->cast<PISerial>();
while (1) {
piMSleep(500);
piCout << s;
if (s)
piCout << s->isOpened();
}
return 0;
PIHash<PIString, PIString> h;
h["1"] = "x";
h["2"] = "bbb";
@@ -331,37 +344,35 @@ int main() {
//h.reserve(64);
//piCout << h.keys() << h.values();
//piCout << (1 << 2);
PIHash<int, PIString> h2;
PIMap<int, PIString> m2;
PIVector<int> keys;
PIString prefix = "1234567890fgbjyfjyjbghjkbgkbgjgsfh jhfgj ghfjhjfjf";
PIHash<PIString, PIString> h2;
PIMap<PIString, PIString> m2;
PIString prefix = "1234567890";
PITimeMeasurer tm;
double el = 0.;
for (int i=0; i<100000; ++i) keys << randomi();
piCout << keys.size();
tm.reset();
for (int i=0; i<100000; ++i) {
h2[keys[i]] = prefix;
for (int i=0; i<10000; ++i) {
h2[prefix + PIString::fromNumber(i)+"1234567890"] = PIString::fromNumber(randomi());
}
el = tm.elapsed_m(); piCout << el << h2.capacity();
tm.reset();
for (int i=0; i<100000; ++i) {
m2[keys[i]] = prefix;
for (int i=0; i<10000; ++i) {
m2[prefix + PIString::fromNumber(i)+"1234567890"] = PIString::fromNumber(randomi());
}
el = tm.elapsed_m(); piCout << el;
piCout << "*********";
PIString _s;
tm.reset();
for (int i=0; i<100000; ++i) {
_s = h2.value(keys[i]);
for (int i=10000; i>=0; --i) {
_s = h2.value(prefix + PIString::fromNumber(i)+"1234567890");
}
el = tm.elapsed_m(); piCout << el << h2.capacity();
tm.reset();
for (int i=0; i<100000; ++i) {
_s = m2.value(keys[i]);
for (int i=10000; i>=0; --i) {
_s = m2.value(prefix + PIString::fromNumber(i)+"1234567890");
}
el = tm.elapsed_m(); piCout << el;