]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/numeric/ublas/benchmarks/bench4/bench4.cpp
2 // Copyright (c) 2000-2002
3 // Joerg Walter, Mathias Koch
5 // Distributed under the Boost Software License, Version 1.0. (See
6 // accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // The authors gratefully acknowledge the support of
10 // GeNeSys mbH & Co. KG in producing this work.
13 #include <boost/numeric/interval.hpp>
14 #include <boost/numeric/interval/io.hpp>
15 #include "../bench1/bench1.hpp"
17 void header (std::string text
) {
18 std::cout
<< text
<< std::endl
;
25 void operator () (int runs
) const {
29 for (int i
= 0; i
< runs
; ++ i
) {
33 footer
<value_type
> () (0, 1, runs
, t
.elapsed ());
35 catch (std::exception
&e
) {
36 std::cout
<< e
.what () << std::endl
;
41 struct peak_c_multiplies
{
44 void operator () (int runs
) const {
48 for (int i
= 0; i
< runs
; ++ i
) {
52 footer
<value_type
> () (0, 1, runs
, t
.elapsed ());
54 catch (std::exception
&e
) {
55 std::cout
<< e
.what () << std::endl
;
61 void peak
<T
>::operator () (int runs
) {
65 peak_c_plus
<T
> () (runs
);
67 header ("multiplies");
68 peak_c_multiplies
<T
> () (runs
);
71 template struct peak
<boost::numeric::interval
<float> >;
72 template struct peak
<boost::numeric::interval
<double> >;
74 #ifdef USE_BOOST_COMPLEX
76 template struct peak
<boost::complex<boost::numeric::interval
<float> > >;
77 template struct peak
<boost::complex<boost::numeric::interval
<double> > >;
83 template <typename scalar
>
84 void do_bench (std::string type_string
, int scale
)
87 peak
<scalar
> () (1000000 * scale
);
89 header (type_string
+ ", 3");
90 bench_1
<scalar
, 3> () (1000000 * scale
);
91 bench_2
<scalar
, 3> () (300000 * scale
);
92 bench_3
<scalar
, 3> () (100000 * scale
);
94 header (type_string
+ ", 10");
95 bench_1
<scalar
, 10> () (300000 * scale
);
96 bench_2
<scalar
, 10> () (30000 * scale
);
97 bench_3
<scalar
, 10> () (3000 * scale
);
99 header (type_string
+ ", 30");
100 bench_1
<scalar
, 30> () (100000 * scale
);
101 bench_2
<scalar
, 30> () (3000 * scale
);
102 bench_3
<scalar
, 30> () (100 * scale
);
104 header (type_string
+ ", 100");
105 bench_1
<scalar
, 100> () (30000 * scale
);
106 bench_2
<scalar
, 100> () (300 * scale
);
107 bench_3
<scalar
, 100> () (3 * scale
);
110 int main (int argc
, char *argv
[]) {
114 scale
= std::atoi (argv
[1]);
117 do_bench
<boost::numeric::interval
<float> > ("boost::numeric::interval<FLOAT>", scale
);
121 do_bench
<boost::numeric::interval
<double> > ("boost::numeric::interval<DOUBLE>", scale
);
124 #ifdef USE_STD_COMPLEX
126 do_bench
<std::complex<boost::numeric::interval
<float> > > ("boost::numeric::interval<COMPLEX<FLOAT>>", scale
);
130 do_bench
<std::complex<doublboost::numeric::interval
<double> > > ("boost::numeric::interval<COMPLEX<DOUBLE>>", scale
);