summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/kernel/lambda-test.cpp
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-05-29 19:44:35 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-05-29 19:44:35 +0000
commite5a49fff24c79431782da107185431b7835ef492 (patch)
tree8bb6ca1aaad4fed82443dcb7d420533c31eb3eb4 /sca-cpp/trunk/kernel/lambda-test.cpp
parent7eef73b80c5f6c4f34f57cc48a46383689acecca (diff)
Fix distribution build, add missing files and samples and fix path to libraries. GCC 4.5 is used if available but not installed automatically.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@949435 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/kernel/lambda-test.cpp')
-rw-r--r--sca-cpp/trunk/kernel/lambda-test.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/sca-cpp/trunk/kernel/lambda-test.cpp b/sca-cpp/trunk/kernel/lambda-test.cpp
index de702b778a..a72f01fb43 100644
--- a/sca-cpp/trunk/kernel/lambda-test.cpp
+++ b/sca-cpp/trunk/kernel/lambda-test.cpp
@@ -27,9 +27,12 @@
#include "function.hpp"
#include "sstream.hpp"
#include "fstream.hpp"
+#include "perf.hpp"
namespace tuscany {
+#ifdef WANT_GCC45
+
const lambda<const int(const int)> inc(const int i) {
return [=](const int x)->const int {
return x + i;
@@ -64,12 +67,34 @@ bool testLambda() {
return true;
}
+const double fib_aux(const double n, const double a, const double b) {
+ return n == 0.0? a : fib_aux(n - 1.0, b, a + b);
+}
+
+const bool fibMapPerf() {
+ list<double> s = seq(0.0, 4999.0);
+ list<double> r = map<double, double>([](const double n)->const double { return fib_aux(n, 0.0, 1.0); }, s);
+ assert(5000 == length(r));
+ return true;
+}
+
+bool testCppPerf() {
+ cout << "Fibonacci map test " << (time([]()->const bool { return fibMapPerf(); }, 1, 1) / 5000) << " ms" << endl;
+ return true;
+}
+
+#endif
}
int main() {
tuscany::cout << "Testing..." << tuscany::endl;
+#ifdef WANT_GCC45
tuscany::testLambda();
+ tuscany::testCppPerf();
+#else
+ tuscany::cout << "Skipped GCC 4.5 tests" << tuscany::endl;
+#endif
tuscany::cout << "OK" << tuscany::endl;