ultimatepp/benchmarks/Sort/Sort.cpp
cxl dc23d485c1 .benchmarks
git-svn-id: svn://ultimatepp.org/upp/trunk@15353 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2020-11-04 09:00:00 +00:00

69 lines
1.3 KiB
C++

#include <Core/Core.h>
#include <TestData/TestData.h>
#include <algorithm>
#include <vector>
using namespace Upp;
CONSOLE_APP_MAIN
{
StdLogSetup(LOG_COUT|LOG_FILE);
RDUMP(AliceWords().GetCount());
for(int i = 0; i < 300; i++) {
Vector<String> w = AliceWords();
std::vector<std::string> x;
{
for(auto s : w)
x.push_back(s.ToStd());
RTIMING("std::sort std::vector<std::string>");
std::sort(x.begin(), x.end());
}
Vector<String> w2 = clone(w);
{
RTIMING("Sort Vector<String>");
Sort(w2);
}
for(int i = 0; i < w2.GetCount(); i++)
if(w2[i] != x[i])
Panic("Failed!");
/* {
std::vector<std::string> x;
for(auto s : w)
x.push_back(s.ToStd());
RTIMING("std::sort std::vector<std::string>");
std::stable_sort(x.begin(), x.end());
}
*/ #if 0
ONCELOCK {
RDUMPC(w);
}
#endif
}
for(int i = 0; i < 300; i++) {
Vector<int> w;
for(int i = 0; i < 40000; i++)
w.Add(Random());
{
std::vector<int> x(w.begin(), w.end());
RTIMING("std::sort std::vector<int>");
std::sort(x.begin(), x.end());
}
{
std::vector<int> x(w.begin(), w.end());
RTIMING("std::sort std::vector<int>");
std::sort(x.begin(), x.end());
}
{
RTIMING("Sort Vector<int>");
Sort(w);
}
#if 0
ONCELOCK {
RDUMPC(w);
}
#endif
}
}