mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
.benchmarks
git-svn-id: svn://ultimatepp.org/upp/trunk@15353 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
bead37087d
commit
dc23d485c1
4 changed files with 96 additions and 8 deletions
|
|
@ -6,6 +6,16 @@
|
|||
|
||||
using namespace Upp;
|
||||
|
||||
namespace std {
|
||||
template<> struct hash<String>
|
||||
{
|
||||
std::size_t operator()(const String& k) const
|
||||
{
|
||||
return GetHashValue(k);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
StdLogSetup(LOG_COUT|LOG_FILE);
|
||||
|
|
@ -19,26 +29,98 @@ CONSOLE_APP_MAIN
|
|||
|
||||
for(int i = 0; i < 100; i++) {
|
||||
Index<String> ndx;
|
||||
SortedIndex<String> ndx2;
|
||||
std::set<std::string> st;
|
||||
std::set<std::string> hst;
|
||||
std::set<String> sst;
|
||||
std::unordered_set<std::string> hst;
|
||||
std::unordered_set<String> hsst;
|
||||
{
|
||||
RTIMING("Index");
|
||||
for(const String& s : w)
|
||||
ndx.FindAdd(s);
|
||||
}
|
||||
{
|
||||
RTIMING("SortedIndex");
|
||||
for(const String& s : w)
|
||||
ndx2.FindAdd(s);
|
||||
}
|
||||
{
|
||||
RTIMING("set");
|
||||
for(const std::string& s : q)
|
||||
st.insert(s);
|
||||
}
|
||||
{
|
||||
RTIMING("set String");
|
||||
for(const String& s : w)
|
||||
sst.insert(s);
|
||||
}
|
||||
{
|
||||
RTIMING("unordered_set");
|
||||
for(const std::string& s : q)
|
||||
hst.insert(s);
|
||||
}
|
||||
{
|
||||
RTIMING("unordered_set String");
|
||||
for(const String& s : w)
|
||||
hsst.insert(s);
|
||||
}
|
||||
ONCELOCK {
|
||||
RDUMP(ndx.GetCount());
|
||||
RDUMP(ndx2.GetCount());
|
||||
RDUMP(st.size());
|
||||
RDUMP(sst.size());
|
||||
RDUMP(hst.size());
|
||||
}
|
||||
}
|
||||
|
||||
w = AliceLines();
|
||||
|
||||
q.clear();
|
||||
for(auto s : w)
|
||||
q.push_back(s.ToStd());
|
||||
|
||||
for(int i = 0; i < 100; i++) {
|
||||
Index<String> ndx;
|
||||
SortedIndex<String> ndx2;
|
||||
std::set<std::string> st;
|
||||
std::set<String> sst;
|
||||
std::unordered_set<std::string> hst;
|
||||
std::unordered_set<String> hsst;
|
||||
{
|
||||
RTIMING("Index");
|
||||
for(const String& s : w)
|
||||
ndx.FindAdd(s);
|
||||
}
|
||||
{
|
||||
RTIMING("SortedIndex");
|
||||
for(const String& s : w)
|
||||
ndx2.FindAdd(s);
|
||||
}
|
||||
{
|
||||
RTIMING("set");
|
||||
for(const std::string& s : q)
|
||||
st.insert(s);
|
||||
}
|
||||
{
|
||||
RTIMING("set String");
|
||||
for(const String& s : w)
|
||||
sst.insert(s);
|
||||
}
|
||||
{
|
||||
RTIMING("unordered_set");
|
||||
for(const std::string& s : q)
|
||||
hst.insert(s);
|
||||
}
|
||||
{
|
||||
RTIMING("unordered_set String");
|
||||
for(const String& s : w)
|
||||
hsst.insert(s);
|
||||
}
|
||||
ONCELOCK {
|
||||
RDUMP(ndx.GetCount());
|
||||
RDUMP(ndx2.GetCount());
|
||||
RDUMP(st.size());
|
||||
RDUMP(sst.size());
|
||||
RDUMP(hst.size());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,5 +6,6 @@ file
|
|||
IndexStd.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "";
|
||||
"" = "",
|
||||
"" = "USEMALLOC";
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ CONSOLE_APP_MAIN
|
|||
RDUMP(AliceWords().GetCount());
|
||||
for(int i = 0; i < 300; i++) {
|
||||
Vector<String> w = AliceWords();
|
||||
std::vector<std::string> x;
|
||||
{
|
||||
std::vector<std::string> x;
|
||||
for(auto s : w)
|
||||
x.push_back(s.ToStd());
|
||||
RTIMING("std::sort std::vector<std::string>");
|
||||
|
|
@ -21,17 +21,21 @@ CONSOLE_APP_MAIN
|
|||
}
|
||||
Vector<String> w2 = clone(w);
|
||||
{
|
||||
RTIMING("StableSort Vector<String>");
|
||||
StableSort(w2);
|
||||
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
|
||||
*/ #if 0
|
||||
ONCELOCK {
|
||||
RDUMPC(w);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ CONSOLE_APP_MAIN
|
|||
double t = tm.Seconds();
|
||||
RLOG(n << " " << t << " s");
|
||||
}
|
||||
|
||||
/*
|
||||
Buffer<int> aq(N);
|
||||
RLOG("Generating antiqsort");
|
||||
antiqsort(N, aq);
|
||||
|
|
@ -96,4 +96,5 @@ CONSOLE_APP_MAIN
|
|||
Sort(h);
|
||||
double t = tm.Seconds();
|
||||
RLOG("antiqsort " << t << " s");
|
||||
*/
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue