]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/local_function/example/profile_cxx11_lambda.cpp
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
8 #include <boost/config.hpp>
9 #ifdef BOOST_NO_CXX11_LAMBDAS
10 # error "lambda functions required"
13 #include <boost/chrono.hpp>
17 #include "profile_helpers.hpp"
19 int main(int argc
, char* argv
[]) {
20 unsigned long size
= 0, trials
= 0;
21 profile::args(argc
, argv
, size
, trials
);
26 std::vector
<double> v(size
);
27 std::fill(v
.begin(), v
.end(), 1.0);
29 boost::chrono::duration
<double> trials_sec
;
30 for(unsigned long i
= 0; i
< trials
; ++i
) {
31 boost::chrono::system_clock::time_point start
=
32 boost::chrono::system_clock::now();
33 std::for_each(v
.begin(), v
.end(), [&sum
, factor
](const double& num
) {
36 trials_sec
+= boost::chrono::system_clock::now() - start
;
39 profile::display(size
, trials
, sum
, trials_sec
.count());