1
0
Fork 0

added test case

This commit is contained in:
Jan Steemann 2013-11-20 23:05:55 +01:00
parent 5a9305ca74
commit adcc26c331
1 changed files with 90 additions and 108 deletions

View File

@ -48,11 +48,6 @@ static bool CreateIndex (SimpleHttpClient*, const string&, const string&, const
// --SECTION-- version retrieval test // --SECTION-- version retrieval test
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Benchmark
/// @{
////////////////////////////////////////////////////////////////////////////////
struct VersionTest : public BenchmarkOperation { struct VersionTest : public BenchmarkOperation {
VersionTest () VersionTest ()
: BenchmarkOperation () { : BenchmarkOperation () {
@ -88,19 +83,10 @@ struct VersionTest : public BenchmarkOperation {
}; };
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- document CRUD append test // --SECTION-- document CRUD append test
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Benchmark
/// @{
////////////////////////////////////////////////////////////////////////////////
struct DocumentCrudAppendTest : public BenchmarkOperation { struct DocumentCrudAppendTest : public BenchmarkOperation {
DocumentCrudAppendTest () DocumentCrudAppendTest ()
: BenchmarkOperation () { : BenchmarkOperation () {
@ -200,19 +186,98 @@ struct DocumentCrudAppendTest : public BenchmarkOperation {
}; };
//////////////////////////////////////////////////////////////////////////////// // -----------------------------------------------------------------------------
/// @} // --SECTION-- shapes test
//////////////////////////////////////////////////////////////////////////////// // -----------------------------------------------------------------------------
struct ShapesTest : public BenchmarkOperation {
ShapesTest ()
: BenchmarkOperation () {
}
~ShapesTest () {
}
bool setUp (SimpleHttpClient* client) {
return DeleteCollection(client, Collection) &&
CreateCollection(client, Collection, 2);
}
void tearDown () {
}
string url (const int threadNumber, const size_t threadCounter, const size_t globalCounter) {
const size_t mod = globalCounter % 3;
if (mod == 0) {
return string("/_api/document?collection=" + Collection);
}
else {
size_t keyId = (size_t) (globalCounter / 3);
const string key = "testkey" + StringUtils::itoa(keyId);
return string("/_api/document/" + Collection + "/" + key);
}
}
HttpRequest::HttpRequestType type (const int threadNumber, const size_t threadCounter, const size_t globalCounter) {
const size_t mod = globalCounter % 3;
if (mod == 0) {
return HttpRequest::HTTP_REQUEST_POST;
}
else if (mod == 1) {
return HttpRequest::HTTP_REQUEST_GET;
}
else {
return HttpRequest::HTTP_REQUEST_DELETE;
}
}
const char* payload (size_t* length, const int threadNumber, const size_t threadCounter, const size_t globalCounter, bool* mustFree) {
const size_t mod = globalCounter % 3;
if (mod == 0) {
const uint64_t n = Complexity;
TRI_string_buffer_t* buffer;
buffer = TRI_CreateSizedStringBuffer(TRI_UNKNOWN_MEM_ZONE, 256);
TRI_AppendStringStringBuffer(buffer, "{\"_key\":\"");
size_t keyId = (size_t) (globalCounter / 3);
const string key = "testkey" + StringUtils::itoa(keyId);
TRI_AppendStringStringBuffer(buffer, key.c_str());
TRI_AppendStringStringBuffer(buffer, "\"");
for (uint64_t i = 1; i <= n; ++i) {
TRI_AppendStringStringBuffer(buffer, ",\"value");
TRI_AppendUInt64StringBuffer(buffer, (uint64_t) ((globalCounter + i) % (Operations / 10)));
TRI_AppendStringStringBuffer(buffer, "\":\"");
TRI_AppendStringStringBuffer(buffer, "some bogus string value to fill up the datafile...");
}
TRI_AppendStringStringBuffer(buffer, "\"}");
*length = TRI_LengthStringBuffer(buffer);
*mustFree = true;
char* ptr = TRI_StealStringBuffer(buffer);
TRI_FreeStringBuffer(TRI_UNKNOWN_MEM_ZONE, buffer);
return (const char*) ptr;
}
else {
*length = 0;
*mustFree = false;
return (const char*) 0;
}
}
};
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- document CRUD test // --SECTION-- document CRUD test
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Benchmark
/// @{
////////////////////////////////////////////////////////////////////////////////
struct DocumentCrudTest : public BenchmarkOperation { struct DocumentCrudTest : public BenchmarkOperation {
DocumentCrudTest () DocumentCrudTest ()
: BenchmarkOperation () { : BenchmarkOperation () {
@ -315,19 +380,10 @@ struct DocumentCrudTest : public BenchmarkOperation {
}; };
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- edge CRUD test // --SECTION-- edge CRUD test
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Benchmark
/// @{
////////////////////////////////////////////////////////////////////////////////
struct EdgeCrudTest : public BenchmarkOperation { struct EdgeCrudTest : public BenchmarkOperation {
EdgeCrudTest () EdgeCrudTest ()
: BenchmarkOperation () { : BenchmarkOperation () {
@ -432,19 +488,10 @@ struct EdgeCrudTest : public BenchmarkOperation {
}; };
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- skiplist test // --SECTION-- skiplist test
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Benchmark
/// @{
////////////////////////////////////////////////////////////////////////////////
struct SkiplistTest : public BenchmarkOperation { struct SkiplistTest : public BenchmarkOperation {
SkiplistTest () SkiplistTest ()
: BenchmarkOperation () { : BenchmarkOperation () {
@ -535,19 +582,10 @@ struct SkiplistTest : public BenchmarkOperation {
}; };
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- hash test // --SECTION-- hash test
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Benchmark
/// @{
////////////////////////////////////////////////////////////////////////////////
struct HashTest : public BenchmarkOperation { struct HashTest : public BenchmarkOperation {
HashTest () HashTest ()
: BenchmarkOperation () { : BenchmarkOperation () {
@ -638,19 +676,10 @@ struct HashTest : public BenchmarkOperation {
}; };
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- document creation test // --SECTION-- document creation test
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Benchmark
/// @{
////////////////////////////////////////////////////////////////////////////////
struct DocumentCreationTest : public BenchmarkOperation { struct DocumentCreationTest : public BenchmarkOperation {
DocumentCreationTest () DocumentCreationTest ()
: BenchmarkOperation (), : BenchmarkOperation (),
@ -710,19 +739,10 @@ struct DocumentCreationTest : public BenchmarkOperation {
size_t _length; size_t _length;
}; };
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- document creation test // --SECTION-- document creation test
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Benchmark
/// @{
////////////////////////////////////////////////////////////////////////////////
struct CollectionCreationTest : public BenchmarkOperation { struct CollectionCreationTest : public BenchmarkOperation {
CollectionCreationTest () CollectionCreationTest ()
: BenchmarkOperation (), : BenchmarkOperation (),
@ -791,11 +811,6 @@ struct CollectionCreationTest : public BenchmarkOperation {
// --SECTION-- transaction test // --SECTION-- transaction test
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Benchmark
/// @{
////////////////////////////////////////////////////////////////////////////////
struct TransactionAqlTest : public BenchmarkOperation { struct TransactionAqlTest : public BenchmarkOperation {
TransactionAqlTest () TransactionAqlTest ()
: BenchmarkOperation () { : BenchmarkOperation () {
@ -899,19 +914,10 @@ struct TransactionAqlTest : public BenchmarkOperation {
string _c3; string _c3;
}; };
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- transaction test // --SECTION-- transaction test
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Benchmark
/// @{
////////////////////////////////////////////////////////////////////////////////
struct TransactionCountTest : public BenchmarkOperation { struct TransactionCountTest : public BenchmarkOperation {
TransactionCountTest () TransactionCountTest ()
: BenchmarkOperation () { : BenchmarkOperation () {
@ -956,19 +962,10 @@ struct TransactionCountTest : public BenchmarkOperation {
}; };
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- transaction test // --SECTION-- transaction test
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Benchmark
/// @{
////////////////////////////////////////////////////////////////////////////////
struct TransactionMultiTest : public BenchmarkOperation { struct TransactionMultiTest : public BenchmarkOperation {
TransactionMultiTest () TransactionMultiTest ()
: BenchmarkOperation () { : BenchmarkOperation () {
@ -1048,26 +1045,12 @@ struct TransactionMultiTest : public BenchmarkOperation {
// --SECTION-- private variables // --SECTION-- private variables
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Benchmark
/// @{
////////////////////////////////////////////////////////////////////////////////
BenchmarkCounter<uint64_t>* CollectionCreationTest::_counter = 0; BenchmarkCounter<uint64_t>* CollectionCreationTest::_counter = 0;
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- private functions // --SECTION-- private functions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Benchmark
/// @{
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief delete a collection /// @brief delete a collection
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -1211,6 +1194,9 @@ static BenchmarkOperation* GetTestCase (const string& name) {
if (name == "edge") { if (name == "edge") {
return new EdgeCrudTest(); return new EdgeCrudTest();
} }
if (name == "shapes") {
return new ShapesTest();
}
if (name == "crud") { if (name == "crud") {
return new DocumentCrudTest(); return new DocumentCrudTest();
} }
@ -1230,10 +1216,6 @@ static BenchmarkOperation* GetTestCase (const string& name) {
return 0; return 0;
} }
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE // --SECTION-- END-OF-FILE
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------