diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-01-02 10:27:26 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-01-02 10:27:26 +0000 |
commit | 95fa76f5f3208d913320c13a05171ecdcd7134c2 (patch) | |
tree | 872e101cd2fb1505baf313940e48c6b615fd6725 /sca-cpp/trunk/modules/http/curl-test.cpp | |
parent | 1d04916fda43146fb62488c20ba03b7b3006c8e9 (diff) |
Performance improvements when running both in multi-threaded and pre-forked HTTPD. Changed memory management to use Apache APR pools instead of ref counting pointers as it's much faster and easier to integrate with the Python and Ruby interpreters. Changed to use simple pool-based string and stream implementations instead of the STL ones, which cause a lots of mutex locks in a multi-threaded environment. Added build options to compile with threading and profiling.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@895165 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 | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/sca-cpp/trunk/modules/http/curl-test.cpp b/sca-cpp/trunk/modules/http/curl-test.cpp index 01355dd429..4305d2ac38 100644 --- a/sca-cpp/trunk/modules/http/curl-test.cpp +++ b/sca-cpp/trunk/modules/http/curl-test.cpp @@ -24,21 +24,15 @@ */ #include <assert.h> -#include <iostream> -#include <sstream> -#include <string> -#include "slist.hpp" +#include "stream.hpp" +#include "string.hpp" #include "perf.hpp" #include "curl.hpp" namespace tuscany { namespace http { -const bool contains(const std::string& str, const std::string& pattern) { - return str.find(pattern) != str.npos; -} - -std::ostringstream* curlWriter(const std::string& s, std::ostringstream* os) { +ostream* curlWriter(const string& s, ostream* os) { (*os) << s; return os; } @@ -46,16 +40,16 @@ std::ostringstream* curlWriter(const std::string& s, std::ostringstream* os) { const bool testGet() { CURLSession ch; { - std::ostringstream os; - const failable<list<std::ostringstream*>, std::string> r = get<std::ostringstream*>(curlWriter, &os, "http://localhost:8090", ch); + ostringstream os; + const failable<list<ostream*> > r = get<ostream*>(curlWriter, &os, "http://localhost:8090", ch); assert(hasContent(r)); - assert(contains(os.str(), "HTTP/1.1 200 OK")); - assert(contains(os.str(), "It works")); + assert(contains(str(os), "HTTP/1.1 200 OK")); + assert(contains(str(os), "It works")); } { - const failable<value, std::string> r = get("http://localhost:8090", ch); + const failable<value> r = getcontent("http://localhost:8090", ch); assert(hasContent(r)); - assert(contains(content(r), "It works")); + assert(contains(car(reverse(list<value>(content(r)))), "It works")); } return true; } @@ -65,9 +59,9 @@ struct getLoop { getLoop(CURLSession& ch) : ch(ch) { } const bool operator()() const { - const failable<value, std::string> r = get("http://localhost:8090", ch); + const failable<value> r = getcontent("http://localhost:8090", ch); assert(hasContent(r)); - assert(contains(content(r), "It works")); + assert(contains(car(reverse(list<value>(content(r)))), "It works")); return true; } }; @@ -75,7 +69,7 @@ struct getLoop { const bool testGetPerf() { CURLSession ch; lambda<bool()> gl = getLoop(ch); - std::cout << "Static GET test " << time(gl, 5, 200) << " ms" << std::endl; + cout << "Static GET test " << time(gl, 5, 200) << " ms" << endl; return true; } @@ -83,12 +77,12 @@ const bool testGetPerf() { } int main() { - std::cout << "Testing..." << std::endl; + tuscany::cout << "Testing..." << tuscany::endl; tuscany::http::testGet(); tuscany::http::testGetPerf(); - std::cout << "OK" << std::endl; + tuscany::cout << "OK" << tuscany::endl; return 0; } |