Skip to content

Commit 1a39b9e

Browse files
committed
Merge pull request #11 from gfx/benchmark_with_string
use std::string for benchmark
2 parents e699203 + b54c296 commit 1a39b9e

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ test-with-std-move: test/test.cpp timsort.hpp .bin
2525
time ./.bin/$@
2626

2727
bench: example/bench.cpp timsort.hpp .bin
28-
$(COMPILE) $(OPTIMIZE) -std=c++11 -DENABLE_STD_MOVE $< -o .bin/$@
2928
$(CXX) -v
29+
$(COMPILE) $(OPTIMIZE) -std=c++11 -DENABLE_STD_MOVE $< -o .bin/$@
3030
./.bin/$@
3131

3232
coverage:

README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Run `make test` for testing and `make coverage` for test coverage.
2424
COMPATIBILITY
2525
==================
2626

27-
This library is compatible with C++03, but if you give the `-DENABLE_STD_MOVE=1` flag to the compiler, you can sort move-only types (see [#9](https://github.com/gfx/cpp-TimSort/pull/9) for details).
27+
This library is compatible with C++03, but if you give the `-DENABLE_STD_MOVE` flag to the compiler, you can sort move-only types (see [#9](https://github.com/gfx/cpp-TimSort/pull/9) for details).
2828

2929
SEE ALSO
3030
==================
@@ -38,42 +38,42 @@ BENCHMARK
3838
bench.cpp, invoked by `make bench`, is a simple benchmark.
3939
An example output is as follows (timing scale: sec.):
4040

41-
c++ -I. -Wall -Wextra -g -DNDEBUG -O2 -std=c++11 -DENABLE_STD_MOVE example/bench.cpp -o .bin/bench
4241
c++ -v
4342
Apple LLVM version 7.0.0 (clang-700.0.72)
4443
Target: x86_64-apple-darwin14.5.0
4544
Thread model: posix
45+
c++ -I. -Wall -Wextra -g -DNDEBUG -O2 -std=c++11 -DENABLE_STD_MOVE example/bench.cpp -o .bin/bench
4646
./.bin/bench
4747
RANDOMIZED SEQUENCE
4848
[int]
4949
size 100000
50-
std::sort 0.531996
51-
std::stable_sort 0.645782
52-
timsort 1.012254
53-
[boost::rational]
50+
std::sort 0.695253
51+
std::stable_sort 0.868916
52+
timsort 1.255825
53+
[std::string]
5454
size 100000
55-
std::sort 3.466250
56-
std::stable_sort 5.943234
57-
timsort 4.456835
55+
std::sort 3.438217
56+
std::stable_sort 4.122629
57+
timsort 5.791845
5858
REVERSED SEQUENCE
5959
[int]
6060
size 100000
61-
std::sort 0.023546
62-
std::stable_sort 0.399995
63-
timsort 0.014056
64-
[boost::rational]
61+
std::sort 0.045461
62+
std::stable_sort 0.575431
63+
timsort 0.019139
64+
[std::string]
6565
size 100000
66-
std::sort 0.626102
67-
std::stable_sort 7.463993
68-
timsort 0.218232
66+
std::sort 0.586707
67+
std::stable_sort 2.715778
68+
timsort 0.345099
6969
SORTED SEQUENCE
7070
[int]
7171
size 100000
72-
std::sort 0.015051
73-
std::stable_sort 0.074084
74-
timsort 0.007797
75-
[boost::rational]
72+
std::sort 0.021876
73+
std::stable_sort 0.087993
74+
timsort 0.008042
75+
[std::string]
7676
size 100000
77-
std::sort 0.371826
78-
std::stable_sort 1.290227
79-
timsort 0.216113
77+
std::sort 0.402458
78+
std::stable_sort 2.436326
79+
timsort 0.298639

example/bench.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static void bench(int const size, state_t const state) {
2323

2424
std::vector<value_t> a;
2525
for(int i = 0; i < size; ++i) {
26-
a.push_back((i+1) * 10);
26+
a.push_back(boost::lexical_cast<value_t>((i+1) * 10));
2727
}
2828

2929
switch(state) {
@@ -82,8 +82,8 @@ static void doit(int const n, state_t const state) {
8282
std::cerr << "[int]" << std::endl;
8383
bench<int>(n, state);
8484

85-
std::cerr << "[boost::rational]" << std::endl;
86-
bench< boost::rational<long long> >(n, state);
85+
std::cerr << "[std::string]" << std::endl;
86+
bench<std::string>(n, state);
8787
}
8888

8989
int main(int argc, const char *argv[]) {

0 commit comments

Comments
 (0)