]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/numeric/ublas/benchmarks/bench1/bench1.cpp
Add patch for failing prerm scripts
[ceph.git] / ceph / src / boost / libs / numeric / ublas / benchmarks / bench1 / bench1.cpp
CommitLineData
7c673cae
FG
1//
2// Copyright (c) 2000-2002
3// Joerg Walter, Mathias Koch
4//
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)
8//
9// The authors gratefully acknowledge the support of
10// GeNeSys mbH & Co. KG in producing this work.
11//
12
13#include "bench1.hpp"
14
15void header (std::string text) {
16 std::cout << text << std::endl;
17}
18
19template<class T>
20struct peak_c_plus {
21 typedef T value_type;
22
23 void operator () (int runs) const {
24 try {
25 static T s (0);
26 boost::timer t;
27 for (int i = 0; i < runs; ++ i) {
28 s += T (0);
29// sink_scalar (s);
30 }
31 footer<value_type> () (0, 1, runs, t.elapsed ());
32 }
33 catch (std::exception &e) {
34 std::cout << e.what () << std::endl;
35 }
36 }
37};
38template<class T>
39struct peak_c_multiplies {
40 typedef T value_type;
41
42 void operator () (int runs) const {
43 try {
44 static T s (1);
45 boost::timer t;
46 for (int i = 0; i < runs; ++ i) {
47 s *= T (1);
48// sink_scalar (s);
49 }
50 footer<value_type> () (0, 1, runs, t.elapsed ());
51 }
52 catch (std::exception &e) {
53 std::cout << e.what () << std::endl;
54 }
55 }
56};
57
58template<class T>
59void peak<T>::operator () (int runs) {
60 header ("peak");
61
62 header ("plus");
63 peak_c_plus<T> () (runs);
64
65 header ("multiplies");
66 peak_c_multiplies<T> () (runs);
67}
68
69
70template <typename scalar>
71void do_bench (std::string type_string, int scale)
72{
73 header (type_string);
74 peak<scalar> () (1000000 * scale);
75
76 header (type_string + ", 3");
77 bench_1<scalar, 3> () (1000000 * scale);
78 bench_2<scalar, 3> () (300000 * scale);
79 bench_3<scalar, 3> () (100000 * scale);
80
81 header (type_string + ", 10");
82 bench_1<scalar, 10> () (300000 * scale);
83 bench_2<scalar, 10> () (30000 * scale);
84 bench_3<scalar, 10> () (3000 * scale);
85
86 header (type_string + ", 30");
87 bench_1<scalar, 30> () (100000 * scale);
88 bench_2<scalar, 30> () (3000 * scale);
89 bench_3<scalar, 30> () (100 * scale);
90
91 header (type_string + ", 100");
92 bench_1<scalar, 100> () (30000 * scale);
93 bench_2<scalar, 100> () (300 * scale);
94 bench_3<scalar, 100> () (3 * scale);
95}
96
97int main (int argc, char *argv []) {
98
99 int scale = 1;
100 if (argc > 1)
101 scale = std::atoi (argv [1]);
102
103#ifdef USE_FLOAT
104 do_bench<float> ("FLOAT", scale);
105#endif
106
107#ifdef USE_DOUBLE
108 do_bench<double> ("DOUBLE", scale);
109#endif
110
111#ifdef USE_STD_COMPLEX
112#ifdef USE_FLOAT
113 do_bench<std::complex<float> > ("COMPLEX<FLOAT>", scale);
114#endif
115
116#ifdef USE_DOUBLE
117 do_bench<std::complex<double> > ("COMPLEX<DOUBLE>", scale);
118#endif
119#endif
120
121 return 0;
122}