mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
.developing svo_value
git-svn-id: svn://ultimatepp.org/upp/trunk@4402 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
1ae2f1d0a7
commit
d91d3931df
4 changed files with 87 additions and 0 deletions
71
benchmarks/ValueBench/ValueBench.cpp
Normal file
71
benchmarks/ValueBench/ValueBench.cpp
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
#include <Core/Core.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define N 1
|
||||
#else
|
||||
#define N 100000
|
||||
#endif
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
StdLogSetup(LOG_COUT|LOG_FILE);
|
||||
Vector<int> x;
|
||||
Vector<String> xs;
|
||||
for(int i = 0; i < 100; i++) {
|
||||
x.Add(Random(1000));
|
||||
xs.Add(AsString(1000));
|
||||
}
|
||||
int sum;
|
||||
for(int i = 0; i < N; i++) {
|
||||
ValueArray va;
|
||||
{
|
||||
va.Clear();
|
||||
RTIMING("Add int");
|
||||
for(int i = 0; i < 100; i++)
|
||||
va.Add(x[i]);
|
||||
}
|
||||
{
|
||||
RTIMING("Read int");
|
||||
for(int i = 0; i < va.GetCount(); i++)
|
||||
sum += (int)va[i];
|
||||
}
|
||||
{
|
||||
va.Clear();
|
||||
RTIMING("Add String");
|
||||
for(int i = 0; i < 100; i++)
|
||||
va.Add(xs[i]);
|
||||
}
|
||||
{
|
||||
RTIMING("Read String");
|
||||
for(int i = 0; i < va.GetCount(); i++)
|
||||
sum += String(va[i]).GetLength();
|
||||
}
|
||||
Vector<String> vs;
|
||||
{
|
||||
vs.Clear();
|
||||
RTIMING("Add Vector<String>");
|
||||
for(int i = 0; i < 100; i++)
|
||||
vs.Add(xs[i]);
|
||||
}
|
||||
{
|
||||
RTIMING("Read Vector<String>");
|
||||
for(int i = 0; i < vs.GetCount(); i++)
|
||||
sum += vs[i].GetLength();
|
||||
}
|
||||
Vector<Value> vv;
|
||||
{
|
||||
vv.Clear();
|
||||
RTIMING("Add Vector<Value>");
|
||||
for(int i = 0; i < 100; i++)
|
||||
vv.Add(xs[i]);
|
||||
}
|
||||
{
|
||||
RTIMING("Read Vector<Value>");
|
||||
for(int i = 0; i < vv.GetCount(); i++)
|
||||
sum += String(vv[i]).GetLength();
|
||||
}
|
||||
}
|
||||
Cout() << sum << "\n";
|
||||
}
|
||||
11
benchmarks/ValueBench/ValueBench.upp
Normal file
11
benchmarks/ValueBench/ValueBench.upp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
optimize_speed;
|
||||
|
||||
uses
|
||||
Core;
|
||||
|
||||
file
|
||||
ValueBench.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "SSE2 MT";
|
||||
|
||||
4
benchmarks/ValueBench/init
Normal file
4
benchmarks/ValueBench/init
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#ifndef _ValueBench_icpp_init_stub
|
||||
#define _ValueBench_icpp_init_stub
|
||||
#include "Core/init"
|
||||
#endif
|
||||
|
|
@ -104,6 +104,7 @@ void BenchValueMap(const char *file) {
|
|||
c = in.Get();
|
||||
}
|
||||
ValueArray va = map[id];
|
||||
map.Set(id, Null);
|
||||
va.Add(line);
|
||||
map.Set(id, va);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue