Skip to content

Commit 2a726a8

Browse files
committed
Refactored vector bench. Better output , more robust benchmarking (cloberring, minimal timing).
1 parent c774d39 commit 2a726a8

7 files changed

Lines changed: 523 additions & 327 deletions

bench/bench_deque.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@
2121
#include "bench_vector_common.hpp"
2222

2323
template<class IntType, class Operation>
24-
void run_containers(unsigned numit, unsigned numele, bool bp)
24+
void run_containers(runner<IntType, Operation>& r)
2525
{
26-
vector_test_template< std::deque<IntType, std::allocator<IntType> >, Operation >(numit, numele, "std::deque ", bp);
27-
vector_test_template< bc::deque<IntType, std::allocator<IntType> >, Operation >(numit, numele, "deque ", bp);
28-
vector_test_template< bc::deque<IntType, std::allocator<IntType>,
29-
typename bc::deque_options<bc::reservable<true> >::type >, Operation >(numit, numele, "deque(reserv) ", bp);
26+
//First registered container is the baseline (denominator).
27+
r.template add< std::deque<IntType, std::allocator<IntType> > >("std::deque");
28+
r.template add< bc::deque<IntType, std::allocator<IntType> > >("deque");
29+
r.template add< bc::deque<IntType, std::allocator<IntType>,
30+
typename bc::deque_options<bc::reservable<true> >::type> >("deque(resv)");
3031
}
3132

3233
int main()

bench/bench_devector.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
#include "bench_vector_common.hpp"
2222

2323
template<class IntType, class Operation>
24-
void run_containers(unsigned numit, unsigned numele, bool bp)
24+
void run_containers(runner<IntType, Operation>& r)
2525
{
26-
vector_test_template< bc::devector<IntType, std::allocator<IntType> >, Operation >(numit, numele, "devector ", bp);
27-
vector_test_template< bc::deque<IntType, std::allocator<IntType> >, Operation >(numit, numele, "deque ", bp);
28-
vector_test_template< bc::vector<IntType, std::allocator<IntType> >, Operation >(numit, numele, "vector ", bp);
26+
//First registered container is the baseline (denominator).
27+
r.template add< bc::vector<IntType, std::allocator<IntType> > >("vector");
28+
r.template add< bc::deque<IntType, std::allocator<IntType> > >("deque");
29+
r.template add< bc::devector<IntType, std::allocator<IntType> > >("devector");
2930
}
3031

3132
int main()

bench/bench_segtor.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@
2121
#include "bench_vector_common.hpp"
2222

2323
template<class IntType, class Operation>
24-
void run_containers(unsigned numit, unsigned numele, bool bp)
24+
void run_containers(runner<IntType, Operation>& r)
2525
{
26-
vector_test_template< bc::deque<IntType, std::allocator<IntType> >, Operation >(numit, numele, "deque ", bp);
27-
vector_test_template< bc::deque<IntType, std::allocator<IntType>,
28-
typename bc::deque_options<bc::reservable<true> >::type >, Operation >(numit, numele, "deque(reserv) ", bp);
29-
vector_test_template< bc::segtor<IntType, std::allocator<IntType> >, Operation >(numit, numele, "segtor ", bp);
30-
vector_test_template< bc::segtor<IntType, std::allocator<IntType>,
31-
typename bc::segtor_options<bc::reservable<true> >::type >, Operation >(numit, numele, "segtor(reserv) ", bp);
26+
//First registered container is the baseline (denominator).
27+
r.template add< bc::deque<IntType, std::allocator<IntType> > >("deque");
28+
r.template add< bc::deque<IntType, std::allocator<IntType>,
29+
typename bc::deque_options<bc::reservable<true> >::type> >("deque(resv)");
30+
r.template add< bc::segtor<IntType, std::allocator<IntType> > >("segtor");
31+
r.template add< bc::segtor<IntType, std::allocator<IntType>,
32+
typename bc::segtor_options<bc::reservable<true> >::type> >("segtor(resv)");
3233
}
3334

3435
int main()

bench/bench_small_vector.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
#include "bench_vector_common.hpp"
2222

2323
template<class IntType, class Operation>
24-
void run_containers(unsigned numit, unsigned numele, bool bp)
24+
void run_containers(runner<IntType, Operation>& r)
2525
{
26-
vector_test_template< bc::small_vector<IntType, 0, std::allocator<IntType> >, Operation >(numit, numele, "small_vector ", bp);
27-
vector_test_template< std::vector<IntType, std::allocator<IntType> >, Operation >(numit, numele, "std::vector ", bp);
28-
vector_test_template< bc::vector<IntType, std::allocator<IntType> >, Operation >(numit, numele, "vector ", bp);
26+
//First registered container is the baseline (denominator).
27+
r.template add< std::vector<IntType, std::allocator<IntType> > >("std::vector");
28+
r.template add< bc::vector<IntType, std::allocator<IntType> > >("vector");
29+
r.template add< bc::small_vector<IntType, 0, std::allocator<IntType> > >("small_vector");
2930
}
3031

3132
int main()

bench/bench_static_vector.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
#include "bench_vector_common.hpp"
2222

2323
template<class IntType, class Operation>
24-
void run_containers(unsigned numit, unsigned numele, bool bp)
24+
void run_containers(runner<IntType, Operation>& r)
2525
{
26+
//First registered container is the baseline (denominator).
27+
r.template add< std::vector<IntType, std::allocator<IntType> > >("std::vector");
28+
r.template add< bc::vector<IntType, std::allocator<IntType> > >("vector");
2629
//static_vector has a fixed capacity, so it must be sized for the largest
2730
//element count exercised by the harness.
28-
vector_test_template< bc::static_vector<IntType, bench_max_numele>, Operation >(numit, numele, "static_vector ", bp);
29-
vector_test_template< std::vector<IntType, std::allocator<IntType> >, Operation >(numit, numele, "std::vector ", bp);
30-
vector_test_template< bc::vector<IntType, std::allocator<IntType> >, Operation >(numit, numele, "vector ", bp);
31+
r.template add< bc::static_vector<IntType, bench_max_numele> >("static_vector");
3132
}
3233

3334
int main()

bench/bench_vector.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
#include "bench_vector_common.hpp"
2020

2121
template<class IntType, class Operation>
22-
void run_containers(unsigned numit, unsigned numele, bool bp)
22+
void run_containers(runner<IntType, Operation>& r)
2323
{
24-
vector_test_template< std::vector<IntType, std::allocator<IntType> >, Operation >(numit, numele, "std::vector ", bp);
25-
vector_test_template< bc::vector<IntType, std::allocator<IntType> >, Operation >(numit, numele, "vector ", bp);
24+
//First registered container is the baseline (denominator).
25+
r.template add< std::vector<IntType, std::allocator<IntType> > >("std::vector");
26+
r.template add< bc::vector<IntType, std::allocator<IntType> > >("vector");
2627
}
2728

2829
int main()

0 commit comments

Comments
 (0)