mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
.benchmarks
git-svn-id: svn://ultimatepp.org/upp/trunk@11632 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
f6fc5c2afb
commit
0f2ed8ca3c
2 changed files with 63 additions and 0 deletions
54
benchmarks/InVectorVsHeap/InVectorVsHeap.cpp
Normal file
54
benchmarks/InVectorVsHeap/InVectorVsHeap.cpp
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
#include <Core/Core.h>
|
||||||
|
|
||||||
|
#include <queue>
|
||||||
|
|
||||||
|
using namespace Upp;
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
#define M 1
|
||||||
|
#define N 10
|
||||||
|
#else
|
||||||
|
#define M 10000
|
||||||
|
#define N 100
|
||||||
|
#endif
|
||||||
|
|
||||||
|
CONSOLE_APP_MAIN
|
||||||
|
{
|
||||||
|
Vector<int> data;
|
||||||
|
for(int j = 0; j < M; j++) {
|
||||||
|
for(int i = 0; i < N; i++)
|
||||||
|
data.Add(Random());
|
||||||
|
{
|
||||||
|
RTIMING("std::priority_queue");
|
||||||
|
std::priority_queue<int> pq;
|
||||||
|
for(int i = 0; i < N; i++)
|
||||||
|
pq.push(data[i]);
|
||||||
|
while(pq.size()) {
|
||||||
|
DUMP(pq.top());
|
||||||
|
pq.pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LOG("----------------------");
|
||||||
|
LOG("----------------------");
|
||||||
|
{
|
||||||
|
RTIMING("SortedIndex");
|
||||||
|
SortedIndex<int> sv;
|
||||||
|
for(int i = 0; i < N; i++)
|
||||||
|
sv.FindAdd(data[i]);
|
||||||
|
while(sv.GetCount()) {
|
||||||
|
DUMP(sv.Top());
|
||||||
|
sv.Drop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
PriorityQueue<int, String> pq;
|
||||||
|
pq.GetCount();
|
||||||
|
pq.Trim();
|
||||||
|
pq.Top();
|
||||||
|
pq.TopKey();
|
||||||
|
pq.Drop();
|
||||||
|
pq.Pop();
|
||||||
|
*/
|
||||||
9
benchmarks/InVectorVsHeap/InVectorVsHeap.upp
Normal file
9
benchmarks/InVectorVsHeap/InVectorVsHeap.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
uses
|
||||||
|
Core;
|
||||||
|
|
||||||
|
file
|
||||||
|
InVectorVsHeap.cpp;
|
||||||
|
|
||||||
|
mainconfig
|
||||||
|
"" = "";
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue