// // Copyright (c) 2000-2002 // Joerg Walter, Mathias Koch // // Permission to use, copy, modify, distribute and sell this software // and its documentation for any purpose is hereby granted without fee, // provided that the above copyright notice appear in all copies and // that both that copyright notice and this permission notice appear // in supporting documentation. The authors make no representations // about the suitability of this software for any purpose. // It is provided "as is" without express or implied warranty. // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. // #include "bench4.hpp" void header (std::string text) { std::cout << text << std::endl; std::cerr << text << std::endl; } template struct peak_c_plus { typedef T value_type; void operator () (int runs) const { try { static T s (0); boost::timer t; for (int i = 0; i < runs; ++ i) { s += T (0); // sink_scalar (s); } footer () (0, 1, runs, t.elapsed ()); } catch (std::exception &e) { std::cout << e.what () << std::endl; } catch (...) { std::cout << "unknown exception" << std::endl; } } }; template struct peak_c_multiplies { typedef T value_type; void operator () (int runs) const { try { static T s (1); boost::timer t; for (int i = 0; i < runs; ++ i) { s *= T (1); // sink_scalar (s); } footer () (0, 1, runs, t.elapsed ()); } catch (std::exception &e) { std::cout << e.what () << std::endl; } catch (...) { std::cout << "unknown exception" << std::endl; } } }; template void peak::operator () (int runs) { header ("peak"); header ("plus"); peak_c_plus () (runs); header ("multiplies"); peak_c_multiplies () (runs); } template struct peak >; template struct peak >; #ifdef USE_BOOST_COMPLEX template struct peak > >; template struct peak > >; #endif #ifdef BOOST_MSVC // Standard new handler is not standard compliant. #include int __cdecl std_new_handler (unsigned) { throw std::bad_alloc (); } #endif int main (int argc, char *argv []) { #ifdef BOOST_MSVC _set_new_handler (std_new_handler); #endif #ifdef USE_FLOAT header ("boost::numeric::interval"); peak > () (100000000); #endif #ifdef USE_DOUBLE header ("boost::numeric::interval"); peak > () (100000000); #endif #ifdef USE_STD_COMPLEX #ifdef USE_FLOAT header ("std:complex >"); peak > > () (100000000); #endif #ifdef USE_DOUBLE header ("std:complex >"); peak > > () (100000000); #endif #endif int scale = 1; if (argc > 1) #ifndef BOOST_NO_STDC_NAMESPACE scale = std::atoi (argv [1]); #else scale = ::atoi (argv [1]); #endif #ifdef USE_FLOAT header ("boost::numeric::interval, 3"); bench_1, 3> () (1000000 * scale); bench_2, 3> () (300000 * scale); bench_3, 3> () (100000 * scale); header ("boost::numeric::interval, 10"); bench_1, 10> () (300000 * scale); bench_2, 10> () (30000 * scale); bench_3, 10> () (3000 * scale); header ("boost::numeric::interval, 30"); bench_1, 30> () (100000 * scale); bench_2, 30> () (3000 * scale); bench_3, 30> () (100 * scale); header ("boost::numeric::interval, 100"); bench_1, 100> () (30000 * scale); bench_2, 100> () (300 * scale); bench_3, 100> () (3 * scale); #endif #ifdef USE_DOUBLE header ("boost::numeric::interval, 3"); bench_1, 3> () (1000000 * scale); bench_2, 3> () (300000 * scale); bench_3, 3> () (100000 * scale); header ("boost::numeric::interval, 10"); bench_1, 10> () (300000 * scale); bench_2, 10> () (30000 * scale); bench_3, 10> () (3000 * scale); header ("boost::numeric::interval, 30"); bench_1, 30> () (100000 * scale); bench_2, 30> () (3000 * scale); bench_3, 30> () (100 * scale); header ("boost::numeric::interval, 100"); bench_1, 100> () (30000 * scale); bench_2, 100> () (300 * scale); bench_3, 100> () (3 * scale); #endif #ifdef USE_BOOST_COMPLEX #ifdef USE_FLOAT header ("boost::complex >, 3"); bench_1 >, 3> () (1000000 * scale); bench_2 >, 3> () (300000 * scale); bench_3 >, 3> () (100000 * scale); header ("boost::complex >, 10"); bench_1 >, 10> () (300000 * scale); bench_2 >, 10> () (30000 * scale); bench_3 >, 10> () (3000 * scale); header ("boost::complex >, 30"); bench_1 >, 30> () (100000 * scale); bench_2 >, 30> () (3000 * scale); bench_3 >, 30> () (100 * scale); header ("boost::complex >, 100"); bench_1 >, 100> () (30000 * scale); bench_2 >, 100> () (300 * scale); bench_3 >, 100> () (3 * scale); #endif #ifdef USE_DOUBLE header ("boost::complex >, 3"); bench_1 >, 3> () (1000000 * scale); bench_2 >, 3> () (300000 * scale); bench_3 >, 3> () (100000 * scale); header ("boost::complex >, 10"); bench_1 >, 10> () (300000 * scale); bench_2 >, 10> () (30000 * scale); bench_3 >, 10> () (3000 * scale); header ("boost::complex >, 30"); bench_1 >, 30> () (100000 * scale); bench_2 >, 30> () (3000 * scale); bench_3 >, 30> () (100 * scale); header ("boost::complex >, 100"); bench_1 >, 100> () (30000 * scale); bench_2 >, 100> () (300 * scale); bench_3 >, 100> () (3 * scale); #endif #endif return 0; }