summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/components/cache/mcache-test.cpp
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2009-12-26 03:25:16 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2009-12-26 03:25:16 +0000
commitf453584ae0a3ec04f1781fc35b7abe5d139c6679 (patch)
tree6724b533ec950e6dbdd4a6dcd6fafe665aec11e1 /sca-cpp/trunk/components/cache/mcache-test.cpp
parent6f0a80fbc621b205f4e1e222a453087006cce668 (diff)
Added timing functions to measure performance, removed unused cache support, refactored and removed some obsolete tests and adjusted build.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@893937 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-cpp/trunk/components/cache/mcache-test.cpp40
1 files changed, 13 insertions, 27 deletions
diff --git a/sca-cpp/trunk/components/cache/mcache-test.cpp b/sca-cpp/trunk/components/cache/mcache-test.cpp
index 78f0da0465..dc286687c0 100644
--- a/sca-cpp/trunk/components/cache/mcache-test.cpp
+++ b/sca-cpp/trunk/components/cache/mcache-test.cpp
@@ -24,11 +24,9 @@
*/
#include <assert.h>
-#include <sys/time.h>
-#include <time.h>
#include <iostream>
#include <string>
-#include <fstream>
+#include "perf.hpp"
#include "mcache.hpp"
namespace tuscany {
@@ -47,35 +45,23 @@ bool testMemCached() {
return true;
}
-const double duration(struct timeval start, struct timeval end, int count) {
- long t = (end.tv_sec * 1000 + end.tv_usec / 1000) - (start.tv_sec * 1000 + start.tv_usec / 1000);
- return (double)t / (double)count;
-}
-
-bool testGetLoop(const int count, MemCached& ch) {
- if (count == 0)
+struct getLoop {
+ MemCached& ch;
+ getLoop(MemCached& ch) : ch(ch) {
+ }
+ const bool operator()() const {
+ assert(get("c", ch) == value(std::string("CCC")));
return true;
- assert(get("c", ch) == value(std::string("CCC")));
- return testGetLoop(count - 1, ch);
-}
+ }
+};
bool testGetPerf() {
- const int count = 50;
- struct timeval start;
- struct timeval end;
- {
- MemCached ch;
- assert(hasContent(post("c", std::string("CCC"), ch)));
-
- testGetLoop(5, ch);
-
- gettimeofday(&start, NULL);
+ MemCached ch;
+ assert(hasContent(post("c", std::string("CCC"), ch)));
- testGetLoop(count, ch);
+ const lambda<bool()> gl = getLoop(ch);
+ std::cout << "Memcached get test " << time(gl, 5, 200) << " ms" << std::endl;
- gettimeofday(&end, NULL);
- std::cout << "Memcached get test " << duration(start, end, count) << " ms" << std::endl;
- }
return true;
}