My favorites
▼
|
Sign in
upp-mirror
U++ is the C++ development platform
Project Home
Downloads
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
benchmarks
/
longStringBench
/
main.cpp
r5024
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#define NDEBUG
#define _SECURE_SCL 0
#include <Core/Core.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <time.h>
#include <vector>
#include <algorithm>
#include <map>
#include <deque>
#include <string>
#define TEST_HASHMAP
#ifdef TEST_HASHMAP
#ifdef COMPILER_GCC
#include <tr1/unordered_map>
#else
#include <hash_map>
#endif
#endif
using namespace std;
using namespace Upp;
#ifdef _DEBUG
#define N 1
#else
#define N 10000
#define NO_OUTPUT // for benchmark purposes, output is omitted
#endif
void BenchNTL(const char *file) {
FileIn in(file);
if (!in) {
std::cout << "Cannot open input file.\n";
return;
}
VectorMap<String, int> map;
int line = 1;
for(;;) {
int c = in.Get();
if(c < 0) break;
String id;
while(c >= 0 && c != '.') {
if((byte)c >= ' ')
id.Cat(c);
c = in.Get();
}
id.Cat('.');
map.GetAdd(id, 0)++;
}
Vector<int> order = GetSortOrder(map);
#ifndef NO_OUTPUT
for(int i = 0; i < order.GetCount(); i++) {
RLOG(map[order[i]] << ": " << map.GetKey(order[i]));
}
#endif
}
CONSOLE_APP_MAIN
{
String fn;
int argc = CommandLine().GetCount();
const Vector<String>& argv = CommandLine();
if(argc < 1)
fn = GetDataFile("main.cpp");
else
fn = argv[0];
{
BenchNTL(fn);
TimeStop tm;
for(int n = 0; n < N; n++)
BenchNTL(fn);
cout << "NTL time: " << tm.Elapsed() << " ms\n";
}
}
Show details
Hide details
Change log
r4408
by cxl on Jan 13, 2012
Diff
.developing svo_value
Go to:
...hmarks/ValueBench/ValueBench.cpp
...k/benchmarks/idmapBench/main.cpp
/trunk/benchmarks/longStringBench
.../benchmarks/longStringBench/init
...gStringBench/longStringBench.upp
...chmarks/longStringBench/main.cpp
Project members,
sign in
to write a code review
Older revisions
All revisions of this file
File info
Size: 1462 bytes, 86 lines
View raw file
Powered by
Google Project Hosting