$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r70955 - sandbox/local/libs/local/example
From: lorcaminiti_at_[hidden]
Date: 2011-04-03 14:04:14
Author: lcaminiti
Date: 2011-04-03 14:04:13 EDT (Sun, 03 Apr 2011)
New Revision: 70955
URL: http://svn.boost.org/trac/boost/changeset/70955
Log:
Added benchmark files for C++0x lambdas.
Added:
   sandbox/local/libs/local/example/benchmark_cpp0x_lambda.cpp   (contents, props changed)
Added: sandbox/local/libs/local/example/benchmark_cpp0x_lambda.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/benchmark_cpp0x_lambda.cpp	2011-04-03 14:04:13 EDT (Sun, 03 Apr 2011)
@@ -0,0 +1,24 @@
+
+#include <iostream>
+#include <vector>
+#include <algorithm>
+
+#define N 10000
+
+int main() {
+    double sum = 0.0;
+    int factor = 10;
+
+    std::vector<double> v(N * 100);
+    std::fill(v.begin(), v.end(), 10);
+
+    for (size_t n = 0; n < N; ++n) {
+        std::for_each(v.begin(), v.end(), [&sum, factor](double num) {
+            sum += factor * num;
+        });
+    }
+
+    std::cout << sum << std::endl;
+    return 0;
+}
+