• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 // Copyright (C) 2009-2012 Lorenzo Caminiti
3 // Distributed under the Boost Software License, Version 1.0
4 // (see accompanying file LICENSE_1_0.txt or a copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 // Home at http://www.boost.org/libs/local_function
7 
8 #include <boost/spirit/home/phoenix/statement/sequence.hpp>
9 #include <boost/spirit/home/phoenix/core/reference.hpp>
10 #include <boost/spirit/home/phoenix/core/argument.hpp>
11 #include <boost/spirit/home/phoenix/operator/arithmetic.hpp>
12 #include <boost/chrono.hpp>
13 #include <iostream>
14 #include <vector>
15 #include <algorithm>
16 #include "profile_helpers.hpp"
17 
main(int argc,char * argv[])18 int main(int argc, char* argv[]) {
19     unsigned long size = 0, trials = 0;
20     profile::args(argc, argv, size, trials);
21 
22     double sum = 0.0;
23     int factor = 1;
24 
25     std::vector<double> v(size);
26     std::fill(v.begin(), v.end(), 1.0);
27 
28     boost::chrono::duration<double> trials_sec;
29     for(unsigned long i = 0; i < trials; ++i) {
30         boost::chrono::system_clock::time_point start =
31                 boost::chrono::system_clock::now();
32 
33         using boost::phoenix::ref;
34         using boost::phoenix::arg_names::_1;
35         std::for_each(v.begin(), v.end(), (
36             ref(sum) += factor * _1
37         ));
38 
39         trials_sec += boost::chrono::system_clock::now() - start;
40     }
41 
42     profile::display(size, trials, sum, trials_sec.count());
43     return 0;
44 }
45 
46