PIMapIterator

small PIString optimize
general PIChunkStream pack optimization
This commit is contained in:
2020-08-02 15:57:21 +03:00
parent 1fb5356825
commit b468a6d581
7 changed files with 253 additions and 78 deletions

View File

@@ -34,32 +34,81 @@ int main() {
class db {
public:
db() {
name = PIStringAscii("sflner;ljner.vjnrevsg;j35m4;gberjg2mnv");
for (int i=0; i<10000; ++i)
x << sin(double(i)/180.0);
//printf("jkfkhg\n");
}
private:
PIString name;
PIVector<double> x;
};
inline PIByteArray & operator <<(PIByteArray & ba, const db & v) {
PIChunkStream cs;
cs.add(1, v.name).add(2, v.x);
ba << cs.data();
return ba;
}
inline PIByteArray & operator >>(PIByteArray & ba, db & v) {
PIByteArray src; ba >> src; PIChunkStream cs(src);
while (!cs.atEnd()) {
switch (cs.read()) {
case 1: cs.get(v.name); break;
case 2: cs.get(v.x); break;
}
}
return ba;
}
PIEthernet eth;
#include "picodeparser.h"
int main() {
/*PIString s(" 324 654 sf 5fdwg sdfsdf sdfefg");
piCout << s;
piCout << s.replaceAll(' ', '1');*/
piDebug = false;
//PICodeParser cp;
//cp.parseFile("SH_plugin_base.h");
PIMap<int, PIString> m;
m[1] = "one";
m[2] = "two";
auto it = m.riterate();
while (it.next()) {
//it.next();
it.valueRef() << "_!";
piCout << it.key() << it.value();
}
/*eth.__meta_data
piForeachC (auto & i, cp.enums) {
i.
}*/
/*piDebug = false;
double min = -1, max = -1, mean = 0;
for (int i = 0; i < 1; ++i) {
PICodeParser cp;
const int iterations = 50;
db d, d2;
for (int i = 0; i < iterations; ++i) {
//PICodeParser cp;
PITimeMeasurer tm;
cp.parseFile("SH_plugin_base.h");
for (int j = 0; j < 100; ++j) {
PIByteArray ba;
ba << d;
}
//cp.parseFile("SH_plugin_base.h");
double ms = tm.elapsed_m();
if (min < 0) min = ms;
if (max < 0) max = ms;
min = piMin(min, ms);
max = piMax(max, ms);
mean += ms;
PIByteArray ba;
ba << d;
d2.name.clear();
d2.x.clear();
ba >> d2;
}
piDebug = true;
piCout << min << (mean / 50) << max;
piCout << d2.name << d2.x.size_s();
piCout << min << (mean / iterations) << max;*/
}