git-svn-id: svn://db.shs.com.ru/pip@859 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
39
main.cpp
39
main.cpp
@@ -318,6 +318,19 @@ inline PICout operator <<(PICout s, const PIHash<Key, Type> & v) {
|
|||||||
|
|
||||||
|
|
||||||
int main() {
|
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;
|
PIHash<PIString, PIString> h;
|
||||||
h["1"] = "x";
|
h["1"] = "x";
|
||||||
h["2"] = "bbb";
|
h["2"] = "bbb";
|
||||||
@@ -331,37 +344,35 @@ int main() {
|
|||||||
//h.reserve(64);
|
//h.reserve(64);
|
||||||
//piCout << h.keys() << h.values();
|
//piCout << h.keys() << h.values();
|
||||||
//piCout << (1 << 2);
|
//piCout << (1 << 2);
|
||||||
PIHash<int, PIString> h2;
|
PIHash<PIString, PIString> h2;
|
||||||
PIMap<int, PIString> m2;
|
PIMap<PIString, PIString> m2;
|
||||||
PIVector<int> keys;
|
PIString prefix = "1234567890";
|
||||||
PIString prefix = "1234567890fgbjyfjyjbghjkbgkbgjgsfh jhfgj ghfjhjfjf";
|
|
||||||
PITimeMeasurer tm;
|
PITimeMeasurer tm;
|
||||||
double el = 0.;
|
double el = 0.;
|
||||||
for (int i=0; i<100000; ++i) keys << randomi();
|
|
||||||
piCout << keys.size();
|
|
||||||
tm.reset();
|
tm.reset();
|
||||||
for (int i=0; i<100000; ++i) {
|
for (int i=0; i<10000; ++i) {
|
||||||
h2[keys[i]] = prefix;
|
h2[prefix + PIString::fromNumber(i)+"1234567890"] = PIString::fromNumber(randomi());
|
||||||
}
|
}
|
||||||
el = tm.elapsed_m(); piCout << el << h2.capacity();
|
el = tm.elapsed_m(); piCout << el << h2.capacity();
|
||||||
|
|
||||||
tm.reset();
|
tm.reset();
|
||||||
for (int i=0; i<100000; ++i) {
|
for (int i=0; i<10000; ++i) {
|
||||||
m2[keys[i]] = prefix;
|
m2[prefix + PIString::fromNumber(i)+"1234567890"] = PIString::fromNumber(randomi());
|
||||||
}
|
}
|
||||||
el = tm.elapsed_m(); piCout << el;
|
el = tm.elapsed_m(); piCout << el;
|
||||||
piCout << "*********";
|
piCout << "*********";
|
||||||
|
|
||||||
PIString _s;
|
PIString _s;
|
||||||
tm.reset();
|
tm.reset();
|
||||||
for (int i=0; i<100000; ++i) {
|
for (int i=10000; i>=0; --i) {
|
||||||
_s = h2.value(keys[i]);
|
_s = h2.value(prefix + PIString::fromNumber(i)+"1234567890");
|
||||||
}
|
}
|
||||||
el = tm.elapsed_m(); piCout << el << h2.capacity();
|
el = tm.elapsed_m(); piCout << el << h2.capacity();
|
||||||
|
|
||||||
tm.reset();
|
tm.reset();
|
||||||
for (int i=0; i<100000; ++i) {
|
for (int i=10000; i>=0; --i) {
|
||||||
_s = m2.value(keys[i]);
|
_s = m2.value(prefix + PIString::fromNumber(i)+"1234567890");
|
||||||
}
|
}
|
||||||
el = tm.elapsed_m(); piCout << el;
|
el = tm.elapsed_m(); piCout << el;
|
||||||
|
|
||||||
|
|||||||
@@ -348,6 +348,7 @@ int PISerial::convertSpeed(PISerial::Speed speed) {
|
|||||||
case S4000000: return B4000000;
|
case S4000000: return B4000000;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
piCoutObj << "Warning: Unknown speed" << (int)speed << ", using 115200";
|
||||||
return B115200;
|
return B115200;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user