// // 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 "bench2.hpp" void header (std::string text) { std::cout << 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; } } }; 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; } } }; template void peak::operator () (int runs) { header ("peak"); header ("plus"); peak_c_plus () (runs); header ("multiplies"); peak_c_multiplies () (runs); } template void do_bench (std::string type_string, int scale) { header (type_string); peak () (1000000 * scale); header (type_string + ", 3"); bench_1 () (1000000 * scale); bench_2 () (300000 * scale); bench_3 () (100000 * scale); header (type_string + ", 10"); bench_1 () (300000 * scale); bench_2 () (30000 * scale); bench_3 () (3000 * scale); header (type_string + ", 30"); bench_1 () (100000 * scale); bench_2 () (3000 * scale); bench_3 () (100 * scale); header (type_string + ", 100"); bench_1 () (30000 * scale); bench_2 () (300 * scale); bench_3 () (3 * scale); } int main (int argc, char *argv []) { int scale = 1; if (argc > 1) scale = std::atoi (argv [1]); #ifdef USE_FLOAT do_bench ("FLOAT", scale); #endif #ifdef USE_DOUBLE do_bench ("DOUBLE", scale); #endif #ifdef USE_STD_COMPLEX #ifdef USE_FLOAT do_bench > ("COMPLEX", scale); #endif #ifdef USE_DOUBLE do_bench > ("COMPLEX", scale); #endif #endif return 0; }