peer update
git-svn-id: svn://db.shs.com.ru/pip@34 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
147
main.cpp
147
main.cpp
@@ -32,86 +32,93 @@ using namespace PIScreenTypes;
|
||||
template <typename T>
|
||||
class Test {
|
||||
public:
|
||||
Test() {
|
||||
T d0, d1, d2;
|
||||
Test(int cycles) {
|
||||
PITimeMeasurer tm;
|
||||
double tr;
|
||||
piCout << "0";
|
||||
printf("(%p)\n", &d0);
|
||||
printf("(%p)\n", &d1);
|
||||
printf("(%p)\n", &d2);
|
||||
piCout << "";
|
||||
int ss = 512;
|
||||
for (int c = 1; c <= cycles; ++c) {
|
||||
piCout << "*** CYCLE" << c << "***";
|
||||
|
||||
tm.reset();
|
||||
for (int i=0; i<ss; i++) {
|
||||
d0.push_back(i);
|
||||
d1.push_front(i);
|
||||
d2.push_back(i);
|
||||
d2.push_front(i);
|
||||
}
|
||||
tr = tm.elapsed_m();
|
||||
piCout << "1" << tr;
|
||||
piCout << d0.capacity();// << d0;
|
||||
piCout << d1.capacity();// << d1;
|
||||
piCout << d2.capacity();// << d2;
|
||||
piCout << "";
|
||||
{
|
||||
T d0;
|
||||
PICout(0) << "push_back ... " << PICoutManipulators::Flush;
|
||||
tm.reset();
|
||||
for (int i = 0; i < c; i++) {
|
||||
d0.push_back(i);
|
||||
}
|
||||
tr = tm.elapsed_m();
|
||||
piCout << tr << "ms, capacity" << d0.capacity();
|
||||
}
|
||||
|
||||
{
|
||||
T d0;
|
||||
PICout(0) << "push_front ... " << PICoutManipulators::Flush;
|
||||
tm.reset();
|
||||
for (int i = 0; i < c; i++) {
|
||||
d0.push_front(i);
|
||||
}
|
||||
tr = tm.elapsed_m();
|
||||
piCout << tr << "ms, capacity" << d0.capacity();
|
||||
}
|
||||
|
||||
{
|
||||
T d0;
|
||||
PICout(0) << "resize + push_back + pop_front ... " << PICoutManipulators::Flush;
|
||||
tm.reset();
|
||||
d0.resize(c);
|
||||
for (int i = 0; i < c; i++) {
|
||||
d0.push_front(i);
|
||||
d0.pop_front();
|
||||
}
|
||||
tr = tm.elapsed_m();
|
||||
piCout << tr << "ms, capacity" << d0.capacity();
|
||||
}
|
||||
|
||||
{
|
||||
T d0;
|
||||
PICout(0) << "resize + push_front + pop_back ... " << PICoutManipulators::Flush;
|
||||
tm.reset();
|
||||
d0.resize(c);
|
||||
for (int i = 0; i < c; i++) {
|
||||
d0.push_front(i);
|
||||
d0.pop_back();
|
||||
}
|
||||
tr = tm.elapsed_m();
|
||||
piCout << tr << "ms, capacity" << d0.capacity();
|
||||
}
|
||||
|
||||
{
|
||||
T d0, d1;
|
||||
PICout(0) << "resize + push_front + pop_back ... " << PICoutManipulators::Flush;
|
||||
tm.reset();
|
||||
for (int i = 0; i < c; i++) {
|
||||
d0 << i;
|
||||
}
|
||||
piCout << d0;
|
||||
for (int i = 0; i < c; i++) {
|
||||
piCout << i;
|
||||
d1.insert(0, d0);
|
||||
piCout << d1.size() << d1.capacity() << i;
|
||||
piCout << d1;
|
||||
d1.remove(0, i);
|
||||
piCout << d1.size() << d1.capacity() << i;
|
||||
piCout << d1;
|
||||
}
|
||||
tr = tm.elapsed_m();
|
||||
piCout << tr << "ms, capacity" << d0.capacity();
|
||||
}
|
||||
|
||||
tm.reset();
|
||||
for (int i=0; i<ss*ss*ss; i++) {
|
||||
d0.push_back(-i);
|
||||
d0.pop_front();
|
||||
d1.push_front(-i);
|
||||
d1.pop_back();
|
||||
}
|
||||
d2.remove(ss/2, ss);
|
||||
tr = tm.elapsed_m();
|
||||
piCout << "2" << ss*ss << tr;
|
||||
piCout << d0.capacity();// << d0;
|
||||
piCout << d1.capacity();// << d1;
|
||||
piCout << d2.capacity();// << d2;
|
||||
piCout << "";
|
||||
}
|
||||
};
|
||||
|
||||
int main (int argc, char * argv[]) {
|
||||
/*PIFile::FileInfo fi = PIFile::fileInfo(argv[1]);
|
||||
piCout << fi;
|
||||
fi.perm_user = fi.perm_group = fi.perm_other = 7;
|
||||
fi.id_user = 1000;
|
||||
fi.time_access.day--;
|
||||
fi.time_modification.hours++;
|
||||
fi.flags |= PIFile::FileInfo::Hidden;
|
||||
//piCout << PIFile::applyFileInfo(fi);
|
||||
fi = PIFile::fileInfo(argv[1]);
|
||||
piCout << fi;*/
|
||||
/*d0 << 1 << 2 << 3 << 4 << 5;
|
||||
d1 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << 21 << 22 << 23 << 24 << 25 << 26 << 27;
|
||||
std::cout << std::dec;
|
||||
piCout << d0;
|
||||
piCout << d1;
|
||||
d0.remove(0, 2);
|
||||
d0.insert(1, d1);
|
||||
std::cout << std::dec;
|
||||
piCout << d0;
|
||||
d0.clear();
|
||||
piCout << "";
|
||||
for (int i = 0; i < 32; ++i) {
|
||||
if (i % 3 == 2) d2.push_front(i);
|
||||
else d2 << i;
|
||||
}
|
||||
piCout << d2;
|
||||
d2.clear();
|
||||
for (int i = 0; i < 32; ++i) {
|
||||
if (i % 2) d2.push_front(i);
|
||||
else d2 << i;
|
||||
}
|
||||
piCout << d2;*/
|
||||
piCout << "Deque";
|
||||
Test<PIDeque<int> > testd;
|
||||
int cc = PIString(argv[1]).toInt();
|
||||
|
||||
piCout << PICoutManipulators::NewLine << "Vector";
|
||||
Test<PIVector<int> > testv;
|
||||
piCout << "Deque";
|
||||
Test<PIDeque<int> > testd(cc);
|
||||
|
||||
/*piCout << PICoutManipulators::NewLine << "Vector";
|
||||
Test<PIVector<int> > testv(cc);*/
|
||||
|
||||
return 0;
|
||||
/*if (!(argc == 3 || argc == 4)) {
|
||||
|
||||
Reference in New Issue
Block a user