1
0
Fork 0

more test cases

This commit is contained in:
Jan Steemann 2012-09-25 12:55:10 +02:00
parent f13cedf5a1
commit d92f359bda
3 changed files with 103 additions and 12 deletions

View File

@ -84,7 +84,7 @@ namespace triagens {
/// @brief return the payload (body) of the HTTP request to execute
////////////////////////////////////////////////////////////////////////////////
virtual const char* payload (size_t* length) = 0;
virtual const char* payload (size_t*, const size_t) = 0;
////////////////////////////////////////////////////////////////////////////////
/// @brief return the HTTP headers for the oepration to execute

View File

@ -87,6 +87,8 @@ namespace triagens {
_password(password),
_client(0),
_connection(0),
_offset(0),
_counter(0),
_time(0.0) {
}
@ -207,7 +209,7 @@ namespace triagens {
const HttpRequest::HttpRequestType type = _operation->type();
const string url = _operation->url();
size_t payloadLength = 0;
const char* payload = _operation->payload(&payloadLength);
const char* payload = _operation->payload(&payloadLength, _offset + _counter++);
const map<string, string>& headers = _operation->headers();
// headline, e.g. POST /... HTTP/1.1
@ -258,7 +260,7 @@ namespace triagens {
const HttpRequest::HttpRequestType type = _operation->type();
const string url = _operation->url();
size_t payloadLength = 0;
const char* payload = _operation->payload(&payloadLength);
const char* payload = _operation->payload(&payloadLength, _offset + _counter++);
const map<string, string>& headers = _operation->headers();
Timing timer(Timing::TI_WALLCLOCK);
@ -295,6 +297,14 @@ namespace triagens {
public:
////////////////////////////////////////////////////////////////////////////////
/// @brief set the threads offset value
////////////////////////////////////////////////////////////////////////////////
void setOffset (size_t offset) {
_offset = offset;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief return the total time accumulated by the thread
////////////////////////////////////////////////////////////////////////////////
@ -372,6 +382,18 @@ namespace triagens {
triagens::httpclient::GeneralClientConnection* _connection;
////////////////////////////////////////////////////////////////////////////////
/// @brief thread offset value
////////////////////////////////////////////////////////////////////////////////
size_t _offset;
////////////////////////////////////////////////////////////////////////////////
/// @brief thread counter value
////////////////////////////////////////////////////////////////////////////////
size_t _counter;
////////////////////////////////////////////////////////////////////////////////
/// @brief time
////////////////////////////////////////////////////////////////////////////////

View File

@ -37,6 +37,7 @@
#include "BasicsC/init.h"
#include "BasicsC/logging.h"
#include "BasicsC/strings.h"
#include "BasicsC/string-buffer.h"
#include "BasicsC/terminal-utils.h"
#include "Logger/Logger.h"
#include "Rest/Endpoint.h"
@ -86,7 +87,7 @@ struct VersionTest : public BenchmarkOperation {
return HttpRequest::HTTP_REQUEST_GET;
}
const char* payload (size_t* length) {
const char* payload (size_t* length, const size_t counter) {
static const char* payload = "";
*length = 0;
return payload;
@ -103,7 +104,7 @@ struct VersionTest : public BenchmarkOperation {
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- document creation test
// --SECTION-- small document creation test
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
@ -129,7 +130,7 @@ struct SmallDocumentCreationTest : public BenchmarkOperation {
return HttpRequest::HTTP_REQUEST_POST;
}
const char* payload (size_t* length) {
const char* payload (size_t* length, const size_t counter) {
static const char* payload = "{\"test\":1}";
*length = 10;
return payload;
@ -141,6 +142,68 @@ struct SmallDocumentCreationTest : public BenchmarkOperation {
}
};
// -----------------------------------------------------------------------------
// --SECTION-- big document creation test
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup V8Shell
/// @{
////////////////////////////////////////////////////////////////////////////////
struct BigDocumentCreationTest : public BenchmarkOperation {
BigDocumentCreationTest ()
: BenchmarkOperation () {
const size_t n = 100;
_buffer = TRI_CreateStringBuffer(TRI_UNKNOWN_MEM_ZONE);
TRI_AppendCharStringBuffer(_buffer, '{');
for (size_t i = 1; i <= n; ++i) {
TRI_AppendStringStringBuffer(_buffer, "\"test");
TRI_AppendUInt32StringBuffer(_buffer, (uint32_t) i);
TRI_AppendStringStringBuffer(_buffer, "\":\"some test value\"");
if (i != n) {
TRI_AppendCharStringBuffer(_buffer, ',');
}
}
TRI_AppendCharStringBuffer(_buffer, '}');
_length = TRI_LengthStringBuffer(_buffer);
}
~BigDocumentCreationTest () {
TRI_Free(TRI_UNKNOWN_MEM_ZONE, _buffer);
}
const string& url () {
static string url = "/_api/document?collection=ArangoBenchmark&createCollection=true";
return url;
}
const HttpRequest::HttpRequestType type () {
return HttpRequest::HTTP_REQUEST_POST;
}
const char* payload (size_t* length, const size_t counter) {
*length = _length;
return (const char*) _buffer->_buffer;
}
const map<string, string>& headers () {
static const map<string, string> headers;
return headers;
}
TRI_string_buffer_t* _buffer;
size_t _length;
};
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
@ -261,7 +324,7 @@ int main (int argc, char* argv[]) {
BenchmarkCounter<unsigned long> operationsCounter(0, (unsigned long) Operations);
ConditionVariable startCondition;
SmallDocumentCreationTest benchmarkOperation;
BigDocumentCreationTest benchmarkOperation;
vector<Endpoint*> endpoints;
vector<BenchmarkThread*> threads;
@ -280,6 +343,7 @@ int main (int argc, char* argv[]) {
BaseClient.password());
threads.push_back(thread);
thread->setOffset(i * (Operations / Concurrency));
thread->start();
}
@ -312,11 +376,16 @@ int main (int argc, char* argv[]) {
requestTime += threads[i]->getTime();
}
cout << "Total number of operations: " << Operations << ", batch size: " << BatchSize << ", concurrency level: " << Concurrency << endl;
cout << "Request/response duration: " << fixed << requestTime << " s" << endl;
cout << "Total duration: " << fixed << time << " s" << endl;
cout << "Duration per operation: " << fixed << (time / Operations) << " s" << endl;
cout << "Duration per operation per thread: " << fixed << (time / (double) Operations * (double) Concurrency) << " s" << endl << endl;
cout << endl;
cout << "Total number of operations: " << Operations << ", batch size: " << BatchSize << ", concurrency level (threads): " << Concurrency << endl;
cout << "Total request/response duration (sum of all threads): " << fixed << requestTime << " s" << endl;
cout << "Request/response duration (per thread): " << fixed << (requestTime / (double) Concurrency) << " s" << endl;
cout << "Time needed per operation: " << fixed << (time / Operations) << " s" << endl;
cout << "Time needed per operation per thread: " << fixed << (time / (double) Operations * (double) Concurrency) << " s" << endl;
cout << "Elapsed time since start: " << fixed << time << " s" << endl;
cout << endl;
if (operationsCounter.failures() > 0) {
cout << "WARNING: " << operationsCounter.failures() << " request(s) failed!!" << endl << endl;