|
|
|
|
@@ -1,89 +1,114 @@
|
|
|
|
|
#include "pip.h"
|
|
|
|
|
|
|
|
|
|
REGISTER_VARIANT_TYPEINFO(PIVector<double>)
|
|
|
|
|
static const char * smallstr = "abcdef";
|
|
|
|
|
|
|
|
|
|
PIEthernet eth;
|
|
|
|
|
|
|
|
|
|
class OH: public PIObject {
|
|
|
|
|
PIOBJECT(OH)
|
|
|
|
|
public:
|
|
|
|
|
EVENT_HANDLER0(void, eh0) {
|
|
|
|
|
piCout << "eh0";
|
|
|
|
|
}
|
|
|
|
|
EVENT_HANDLER1(void, eh1, PIStringList, sl) {
|
|
|
|
|
piCout << "eh1" << sl;
|
|
|
|
|
}
|
|
|
|
|
EVENT_HANDLER2(void, eh2, PIStringList, sl, const PIVector< double > &, vd) {
|
|
|
|
|
piCout << "eh2" << sl << vd;
|
|
|
|
|
}
|
|
|
|
|
EVENT_HANDLER3(void, eh3, PIStringList, sl, const PIVector<double> &, vd, PISystemTime, st) {
|
|
|
|
|
piCout << "eh3" << sl << vd << st;
|
|
|
|
|
}
|
|
|
|
|
private:
|
|
|
|
|
int cnt = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class OE: public PIThread {
|
|
|
|
|
PIOBJECT_SUBCLASS(OE, PIThread)
|
|
|
|
|
public:
|
|
|
|
|
EVENT0(e0);
|
|
|
|
|
EVENT1(e1, PIStringList, sl);
|
|
|
|
|
EVENT2(e2, PIStringList, sl, PIVector< double>, vd);
|
|
|
|
|
EVENT3(e3, PIStringList, sl, PIVector< double>, vd, PISystemTime, st);
|
|
|
|
|
private:
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
PIThreadNotifier notifier;
|
|
|
|
|
PITimeMeasurer time;
|
|
|
|
|
|
|
|
|
|
class Worker: public PIThread {
|
|
|
|
|
PIOBJECT_SUBCLASS(Worker, PIThread)
|
|
|
|
|
public:
|
|
|
|
|
Worker(const PIString & n) {
|
|
|
|
|
setName(n);
|
|
|
|
|
}
|
|
|
|
|
void run() override {
|
|
|
|
|
piCoutObj << (int)time.elapsed_m() << "wait ...";
|
|
|
|
|
notifier.wait();
|
|
|
|
|
piCoutObj << (int)time.elapsed_m() << "done";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
static const char * bigstr = "zsxdcgfhvbncjdbasljcvavcjadnwnxudvbabdhjlavudvdaljsvclavjlasdhvcjhldsavhjldasvfjlhsavdjhavdjhvfjhldasvfjlasvfhjldasvfhjasvfdjdasfhvjldasvhfjlasvfhjlahsvdfhjfvfvdjalsvfjlhasdvfdjsalvfhhjldasvfdjhaldsvfhjdvsfjhlavfjhlavfladlsvfjlasdvfdhjlavfhjldasvfhjlavfhjldvfhjlalsdvfjlhvasfhjlvchjlavchjladvchjldladvschjlladscvjlhdcahjchjllcahjllvcdjladsvhldbcljadsbcjdhlsachjlvdsa hjlcldajc hljdascbhaldb cldhashd l cajlhs chdsbfhlbfdasdffadsfjkbfkjldsabflhbcldhsbhclabchljadsbchldahsbcladsbhclhabhasbclasbdhl";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char * argv[]) {
|
|
|
|
|
typedef int(*MyFunc)(int,int);
|
|
|
|
|
PILibrary * lib = new PILibrary();
|
|
|
|
|
if (lib->load("libpip_plugin.dll")) {
|
|
|
|
|
MyFunc fadd = (MyFunc)lib->resolve("exportedSum");
|
|
|
|
|
MyFunc fmul = (MyFunc)lib->resolve("exportedMul");
|
|
|
|
|
if (fadd) {
|
|
|
|
|
int sum = fadd(1, 2);
|
|
|
|
|
piCout << "sum =" << sum;
|
|
|
|
|
} else {
|
|
|
|
|
piCout << "Can`t resolve" << "exportedSum";
|
|
|
|
|
}
|
|
|
|
|
if (fmul) {
|
|
|
|
|
int mul = fadd(10, 20);
|
|
|
|
|
piCout << "mul =" << mul;
|
|
|
|
|
} else {
|
|
|
|
|
piCout << "Can`t resolve" << "exportedMul";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
piCout << lib->lastError();
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
delete lib;
|
|
|
|
|
/*OH oh;
|
|
|
|
|
OE oe;
|
|
|
|
|
CONNECTU(&oe, e3, &oh, eh0);
|
|
|
|
|
CONNECTU(&oe, e3, &oh, eh1);
|
|
|
|
|
CONNECTU(&oe, e3, &oh, eh2);
|
|
|
|
|
CONNECTU(&oe, e3, &oh, eh3);
|
|
|
|
|
//oh.dump();
|
|
|
|
|
oe.dump();
|
|
|
|
|
oe.e0();
|
|
|
|
|
oe.e1({"a", "b", "c"});
|
|
|
|
|
oe.e2({"a", "b", "c"}, {1., 1.5, 2.});
|
|
|
|
|
oe.e3({"a", "b", "c"}, {1., 1.5, 2.}, PISystemTime::current());
|
|
|
|
|
//piCout << oe.methodsEH();*/
|
|
|
|
|
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();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|