diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2009-12-26 03:25:16 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2009-12-26 03:25:16 +0000 |
commit | f453584ae0a3ec04f1781fc35b7abe5d139c6679 (patch) | |
tree | 6724b533ec950e6dbdd4a6dcd6fafe665aec11e1 /sca-cpp/trunk/modules/http/curl-test.cpp | |
parent | 6f0a80fbc621b205f4e1e222a453087006cce668 (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 'sca-cpp/trunk/modules/http/curl-test.cpp')
-rw-r--r-- | sca-cpp/trunk/modules/http/curl-test.cpp | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/sca-cpp/trunk/modules/http/curl-test.cpp b/sca-cpp/trunk/modules/http/curl-test.cpp index 59944546a1..01355dd429 100644 --- a/sca-cpp/trunk/modules/http/curl-test.cpp +++ b/sca-cpp/trunk/modules/http/curl-test.cpp @@ -24,12 +24,11 @@ */ #include <assert.h> -#include <sys/time.h> -#include <time.h> #include <iostream> #include <sstream> #include <string> #include "slist.hpp" +#include "perf.hpp" #include "curl.hpp" namespace tuscany { @@ -39,11 +38,6 @@ const bool contains(const std::string& str, const std::string& pattern) { return str.find(pattern) != str.npos; } -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; -} - std::ostringstream* curlWriter(const std::string& s, std::ostringstream* os) { (*os) << s; return os; @@ -66,30 +60,22 @@ const bool testGet() { return true; } -const bool testGetLoop(const int count, CURLSession& ch) { - if (count == 0) +struct getLoop { + CURLSession& ch; + getLoop(CURLSession& ch) : ch(ch) { + } + const bool operator()() const { + const failable<value, std::string> r = get("http://localhost:8090", ch); + assert(hasContent(r)); + assert(contains(content(r), "It works")); return true; - const failable<value, std::string> r = get("http://localhost:8090", ch); - assert(hasContent(r)); - assert(contains(content(r), "It works")); - return testGetLoop(count - 1, ch); -} + } +}; const bool testGetPerf() { - const int count = 50; CURLSession ch; - struct timeval start; - struct timeval end; - { - testGetLoop(5, ch); - - gettimeofday(&start, NULL); - - testGetLoop(count, ch); - - gettimeofday(&end, NULL); - std::cout << "Static GET test " << duration(start, end, count) << " ms" << std::endl; - } + lambda<bool()> gl = getLoop(ch); + std::cout << "Static GET test " << time(gl, 5, 200) << " ms" << std::endl; return true; } |