forked from boostorg/container
Make sure test suite/examples/bench compile with exceptions disabled (exception-handling=off)
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
#endif
|
||||
|
||||
#include <boost/container/detail/dlmalloc.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/container/throw_exception.hpp>
|
||||
|
||||
#define BOOST_INTERPROCESS_VECTOR_ALLOC_STATS
|
||||
|
||||
@@ -61,7 +63,7 @@ void allocation_timing_test(unsigned int num_iterations, unsigned int num_elemen
|
||||
dlmalloc_free(first_mem);
|
||||
++numalloc;
|
||||
|
||||
try{
|
||||
BOOST_TRY{
|
||||
dlmalloc_command_ret_t ret;
|
||||
for(size_t e = capacity + 1; e < num_elements; ++e){
|
||||
size_t received_size;
|
||||
@@ -73,8 +75,7 @@ void allocation_timing_test(unsigned int num_iterations, unsigned int num_elemen
|
||||
( m_mode, sizeof(POD)
|
||||
, min, max, &received_size, addr);
|
||||
if(!ret.first){
|
||||
std::cout << "(!ret.first)!" << std::endl;
|
||||
throw int(0);
|
||||
throw_runtime_error("!ret.first)");
|
||||
}
|
||||
if(!ret.second){
|
||||
assert(m_mode == BOOST_CONTAINER_ALLOCATE_NEW);
|
||||
@@ -100,10 +101,11 @@ void allocation_timing_test(unsigned int num_iterations, unsigned int num_elemen
|
||||
}
|
||||
dlmalloc_free(addr);
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
dlmalloc_free(addr);
|
||||
throw;
|
||||
BOOST_RETHROW;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
}
|
||||
|
||||
assert( dlmalloc_allocated_memory() == 0);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#endif
|
||||
|
||||
#include <boost/container/allocator.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
|
||||
#define BOOST_CONTAINER_VECTOR_ALLOC_STATS
|
||||
|
||||
@@ -109,7 +110,7 @@ void vector_test_template(unsigned int num_iterations, unsigned int num_elements
|
||||
bc::vector<MyInt, IntAllocator> v;
|
||||
v.reset_alloc_stats();
|
||||
void *first_mem = 0;
|
||||
try{
|
||||
BOOST_TRY{
|
||||
first_mem = bc::dlmalloc_malloc(sizeof(MyInt)*num_elements*3/2);
|
||||
v.push_back(MyInt(0));
|
||||
bc::dlmalloc_free(first_mem);
|
||||
@@ -121,10 +122,11 @@ void vector_test_template(unsigned int num_iterations, unsigned int num_elements
|
||||
numexpand += v.num_expand_bwd;
|
||||
capacity = static_cast<unsigned int>(v.capacity());
|
||||
}
|
||||
catch(...){
|
||||
BOOST_CATCH(...){
|
||||
bc::dlmalloc_free(first_mem);
|
||||
throw;
|
||||
BOOST_RETHROW;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
}
|
||||
|
||||
assert(bc::dlmalloc_allocated_memory() == 0);
|
||||
|
||||
+67
-70
@@ -19,6 +19,7 @@
|
||||
#include <iomanip>
|
||||
#include <boost/container/vector.hpp>
|
||||
#include <boost/container/string.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
|
||||
using boost::timer::cpu_timer;
|
||||
using boost::timer::cpu_times;
|
||||
@@ -394,91 +395,87 @@ template<class BoostClass, class StdClass>
|
||||
void launch_tests(const char *BoostContName, const char *StdContName)
|
||||
{
|
||||
typedef range_provider<typename BoostClass::value_type> get_range_t;
|
||||
try {
|
||||
std::cout << "**********************************************" << '\n';
|
||||
std::cout << "**********************************************" << '\n';
|
||||
std::cout << '\n';
|
||||
std::cout << BoostContName << " .VS " << StdContName << '\n';
|
||||
std::cout << '\n';
|
||||
std::cout << "**********************************************" << '\n';
|
||||
std::cout << "**********************************************" << '\n' << std::endl;
|
||||
{
|
||||
std::cout << "Copy/Assign/Destroy benchmark:" << BoostContName << std::endl;
|
||||
cpu_times boost_set_time = copy_destroy_time< BoostClass >(get_range_t::sorted_unique());
|
||||
|
||||
std::cout << "Copy/Assign/Destroy benchmark:" << StdContName << std::endl;
|
||||
cpu_times std_set_time = copy_destroy_time< StdClass >(get_range_t::sorted_unique());
|
||||
std::cout << "**********************************************" << '\n';
|
||||
std::cout << "**********************************************" << '\n';
|
||||
std::cout << '\n';
|
||||
std::cout << BoostContName << " .VS " << StdContName << '\n';
|
||||
std::cout << '\n';
|
||||
std::cout << "**********************************************" << '\n';
|
||||
std::cout << "**********************************************" << '\n' << std::endl;
|
||||
{
|
||||
std::cout << "Copy/Assign/Destroy benchmark:" << BoostContName << std::endl;
|
||||
cpu_times boost_set_time = copy_destroy_time< BoostClass >(get_range_t::sorted_unique());
|
||||
|
||||
std::cout << BoostContName << "/" << StdContName << ": ";
|
||||
compare_times(boost_set_time, std_set_time);
|
||||
}
|
||||
{
|
||||
std::cout << "Ordered construct benchmark:" << BoostContName << std::endl;
|
||||
cpu_times boost_set_time = construct_time< BoostClass >(get_range_t::sorted_unique(), get_range_t::sorted(), "(ord)");
|
||||
std::cout << "Copy/Assign/Destroy benchmark:" << StdContName << std::endl;
|
||||
cpu_times std_set_time = copy_destroy_time< StdClass >(get_range_t::sorted_unique());
|
||||
|
||||
std::cout << "Ordered construct benchmark:" << StdContName << std::endl;
|
||||
cpu_times std_set_time = construct_time< StdClass >(get_range_t::sorted_unique(), get_range_t::sorted(), "(ord)");;
|
||||
std::cout << BoostContName << "/" << StdContName << ": ";
|
||||
compare_times(boost_set_time, std_set_time);
|
||||
}
|
||||
{
|
||||
std::cout << "Ordered construct benchmark:" << BoostContName << std::endl;
|
||||
cpu_times boost_set_time = construct_time< BoostClass >(get_range_t::sorted_unique(), get_range_t::sorted(), "(ord)");
|
||||
|
||||
std::cout << BoostContName << "/" << StdContName << ": ";
|
||||
compare_times(boost_set_time, std_set_time);
|
||||
}
|
||||
{
|
||||
std::cout << "Random construct benchmark:" << BoostContName << std::endl;
|
||||
cpu_times boost_set_time = construct_time< BoostClass >(get_range_t::random_unique(), get_range_t::random(), "(rnd)");
|
||||
std::cout << "Ordered construct benchmark:" << StdContName << std::endl;
|
||||
cpu_times std_set_time = construct_time< StdClass >(get_range_t::sorted_unique(), get_range_t::sorted(), "(ord)");;
|
||||
|
||||
std::cout << "Random construct benchmark:" << StdContName << std::endl;
|
||||
cpu_times std_set_time = construct_time< StdClass >(get_range_t::random_unique(), get_range_t::random(), "(rnd)");;
|
||||
std::cout << BoostContName << "/" << StdContName << ": ";
|
||||
compare_times(boost_set_time, std_set_time);
|
||||
}
|
||||
{
|
||||
std::cout << "Random construct benchmark:" << BoostContName << std::endl;
|
||||
cpu_times boost_set_time = construct_time< BoostClass >(get_range_t::random_unique(), get_range_t::random(), "(rnd)");
|
||||
|
||||
std::cout << BoostContName << "/" << StdContName << ": ";
|
||||
compare_times(boost_set_time, std_set_time);
|
||||
}
|
||||
{
|
||||
std::cout << "Ordered Insert benchmark:" << BoostContName << std::endl;
|
||||
cpu_times boost_set_time = insert_time< BoostClass >(get_range_t::sorted_unique(), get_range_t::sorted(), "(ord)");
|
||||
std::cout << "Random construct benchmark:" << StdContName << std::endl;
|
||||
cpu_times std_set_time = construct_time< StdClass >(get_range_t::random_unique(), get_range_t::random(), "(rnd)");;
|
||||
|
||||
std::cout << "Ordered Insert benchmark:" << StdContName << std::endl;
|
||||
cpu_times std_set_time = insert_time< StdClass >(get_range_t::sorted_unique(), get_range_t::sorted(), "(ord)");
|
||||
std::cout << BoostContName << "/" << StdContName << ": ";
|
||||
compare_times(boost_set_time, std_set_time);
|
||||
}
|
||||
{
|
||||
std::cout << "Ordered Insert benchmark:" << BoostContName << std::endl;
|
||||
cpu_times boost_set_time = insert_time< BoostClass >(get_range_t::sorted_unique(), get_range_t::sorted(), "(ord)");
|
||||
|
||||
std::cout << BoostContName << "/" << StdContName << ": ";
|
||||
compare_times(boost_set_time, std_set_time);
|
||||
}
|
||||
{
|
||||
std::cout << "Random Insert benchmark:" << BoostContName << std::endl;
|
||||
cpu_times boost_set_time = insert_time< BoostClass >(get_range_t::random_unique(), get_range_t::random(), "(rnd)");
|
||||
std::cout << "Ordered Insert benchmark:" << StdContName << std::endl;
|
||||
cpu_times std_set_time = insert_time< StdClass >(get_range_t::sorted_unique(), get_range_t::sorted(), "(ord)");
|
||||
|
||||
std::cout << "Random Insert benchmark:" << StdContName << std::endl;
|
||||
cpu_times std_set_time = insert_time< StdClass >(get_range_t::random_unique(), get_range_t::random(), "(rnd)");
|
||||
std::cout << BoostContName << "/" << StdContName << ": ";
|
||||
compare_times(boost_set_time, std_set_time);
|
||||
}
|
||||
{
|
||||
std::cout << "Random Insert benchmark:" << BoostContName << std::endl;
|
||||
cpu_times boost_set_time = insert_time< BoostClass >(get_range_t::random_unique(), get_range_t::random(), "(rnd)");
|
||||
|
||||
std::cout << BoostContName << "/" << StdContName << ": ";
|
||||
compare_times(boost_set_time, std_set_time);
|
||||
}
|
||||
{
|
||||
std::cout << "Ordered Search benchmark:" << BoostContName << std::endl;
|
||||
cpu_times boost_set_time = search_time< BoostClass >(get_range_t::sorted_unique(), "(ord)");
|
||||
std::cout << "Random Insert benchmark:" << StdContName << std::endl;
|
||||
cpu_times std_set_time = insert_time< StdClass >(get_range_t::random_unique(), get_range_t::random(), "(rnd)");
|
||||
|
||||
std::cout << "Ordered Search benchmark:" << StdContName << std::endl;
|
||||
cpu_times std_set_time = search_time< StdClass >(get_range_t::sorted_unique(), "(ord)");
|
||||
std::cout << BoostContName << "/" << StdContName << ": ";
|
||||
compare_times(boost_set_time, std_set_time);
|
||||
}
|
||||
{
|
||||
std::cout << "Ordered Search benchmark:" << BoostContName << std::endl;
|
||||
cpu_times boost_set_time = search_time< BoostClass >(get_range_t::sorted_unique(), "(ord)");
|
||||
|
||||
std::cout << BoostContName << "/" << StdContName << ": ";
|
||||
compare_times(boost_set_time, std_set_time);
|
||||
}
|
||||
{
|
||||
std::cout << "Random Search benchmark:" << BoostContName << std::endl;
|
||||
cpu_times boost_set_time = search_time< BoostClass >(get_range_t::random_unique(), "(rnd)");
|
||||
std::cout << "Ordered Search benchmark:" << StdContName << std::endl;
|
||||
cpu_times std_set_time = search_time< StdClass >(get_range_t::sorted_unique(), "(ord)");
|
||||
|
||||
std::cout << "Random Search benchmark:" << StdContName << std::endl;
|
||||
cpu_times std_set_time = search_time< StdClass >(get_range_t::random_unique(), "(rnd)");
|
||||
std::cout << BoostContName << "/" << StdContName << ": ";
|
||||
compare_times(boost_set_time, std_set_time);
|
||||
}
|
||||
{
|
||||
std::cout << "Random Search benchmark:" << BoostContName << std::endl;
|
||||
cpu_times boost_set_time = search_time< BoostClass >(get_range_t::random_unique(), "(rnd)");
|
||||
|
||||
std::cout << BoostContName << "/" << StdContName << ": ";
|
||||
compare_times(boost_set_time, std_set_time);
|
||||
}
|
||||
{
|
||||
std::cout << "Extensions benchmark:" << BoostContName << std::endl;
|
||||
extensions_time< BoostClass >(get_range_t::sorted_unique());
|
||||
}
|
||||
std::cout << "Random Search benchmark:" << StdContName << std::endl;
|
||||
cpu_times std_set_time = search_time< StdClass >(get_range_t::random_unique(), "(rnd)");
|
||||
|
||||
}catch(std::exception &e){
|
||||
std::cout << e.what();
|
||||
std::cout << BoostContName << "/" << StdContName << ": ";
|
||||
compare_times(boost_set_time, std_set_time);
|
||||
}
|
||||
{
|
||||
std::cout << "Extensions benchmark:" << BoostContName << std::endl;
|
||||
extensions_time< BoostClass >(get_range_t::sorted_unique());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
// @brief varray_benchmark.cpp compares the performance of boost::container::varray to boost::container::vector
|
||||
|
||||
#include "varray.hpp"
|
||||
#include "boost/container/vector.hpp"
|
||||
#include "boost/container/static_vector.hpp"
|
||||
#include <boost/container/vector.hpp>
|
||||
#include <boost/container/static_vector.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
|
||||
#include "../test/movable_int.hpp"
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
@@ -114,31 +116,28 @@ void compare_times(cpu_times time_numerator, cpu_times time_denominator){
|
||||
|
||||
int main()
|
||||
{
|
||||
try {
|
||||
std::cout << "N = " << N << " Iter = " << Iter << "\n\n";
|
||||
std::cout << "N = " << N << " Iter = " << Iter << "\n\n";
|
||||
|
||||
std::cout << "varray benchmark:" << std::endl;
|
||||
cpu_times time_varray = time_it<boost::container::varray<boost::container::varray<basic_type_t,N>,N > >();
|
||||
std::cout << "varray benchmark:" << std::endl;
|
||||
cpu_times time_varray = time_it<boost::container::varray<boost::container::varray<basic_type_t,N>,N > >();
|
||||
|
||||
std::cout << "boost::container::static_vector benchmark" << std::endl;
|
||||
cpu_times time_boost_static_vector = time_it<boost::container::static_vector<boost::container::static_vector<basic_type_t,N>,N > >();
|
||||
std::cout << "boost::container::static_vector benchmark" << std::endl;
|
||||
cpu_times time_boost_static_vector = time_it<boost::container::static_vector<boost::container::static_vector<basic_type_t,N>,N > >();
|
||||
|
||||
std::cout << "boost::container::vector benchmark" << std::endl;
|
||||
cpu_times time_boost_vector = time_it<boost::container::vector<boost::container::vector<basic_type_t> > >();
|
||||
std::cout << "boost::container::vector benchmark" << std::endl;
|
||||
cpu_times time_boost_vector = time_it<boost::container::vector<boost::container::vector<basic_type_t> > >();
|
||||
|
||||
std::cout << "std::vector benchmark" << std::endl;
|
||||
cpu_times time_standard_vector = time_it<std::vector<std::vector<basic_type_t> > >();
|
||||
std::cout << "std::vector benchmark" << std::endl;
|
||||
cpu_times time_standard_vector = time_it<std::vector<std::vector<basic_type_t> > >();
|
||||
|
||||
std::cout << "varray/boost::container::vector total time comparison:";
|
||||
compare_times(time_varray, time_boost_vector);
|
||||
std::cout << "varray/boost::container::vector total time comparison:";
|
||||
compare_times(time_varray, time_boost_vector);
|
||||
|
||||
std::cout << "varray/boost::container::static_vector total time comparison:";
|
||||
compare_times(time_varray, time_boost_static_vector);
|
||||
std::cout << "varray/boost::container::static_vector total time comparison:";
|
||||
compare_times(time_varray, time_boost_static_vector);
|
||||
|
||||
std::cout << "varray/std::vector total time comparison:";
|
||||
compare_times(time_varray,time_standard_vector);
|
||||
|
||||
std::cout << "varray/std::vector total time comparison:";
|
||||
compare_times(time_varray,time_standard_vector);
|
||||
}catch(std::exception &e){
|
||||
std::cout << e.what();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user