Electroneum
schematest.cpp File Reference
#include "perftest.h"
#include "rapidjson/schema.h"
#include <ctime>
#include <string>
#include <vector>
Include dependency graph for schematest.cpp:

Go to the source code of this file.

Classes

class  Schema
 
struct  Schema::TestSuite
 

Macros

#define ARRAY_SIZE(a)   sizeof(a) / sizeof(a[0])
 

Functions

 TEST_F (Schema, TestSuite)
 

Macro Definition Documentation

◆ ARRAY_SIZE

#define ARRAY_SIZE (   a)    sizeof(a) / sizeof(a[0])

Definition at line 10 of file schematest.cpp.

Function Documentation

◆ TEST_F()

TEST_F ( Schema  ,
TestSuite   
)

Definition at line 191 of file schematest.cpp.

191  {
192  char validatorBuffer[65536];
193  MemoryPoolAllocator<> validatorAllocator(validatorBuffer, sizeof(validatorBuffer));
194 
195  const int trialCount = 100000;
196  int testCount = 0;
197  clock_t start = clock();
198  for (int i = 0; i < trialCount; i++) {
199  for (TestSuiteList::const_iterator itr = testSuites.begin(); itr != testSuites.end(); ++itr) {
200  const TestSuite& ts = **itr;
201  GenericSchemaValidator<SchemaDocument, BaseReaderHandler<UTF8<> >, MemoryPoolAllocator<> > validator(*ts.schema, &validatorAllocator);
202  for (DocumentList::const_iterator testItr = ts.tests.begin(); testItr != ts.tests.end(); ++testItr) {
203  validator.Reset();
204  (*testItr)->Accept(validator);
205  testCount++;
206  }
207  validatorAllocator.Clear();
208  }
209  }
210  clock_t end = clock();
211  double duration = double(end - start) / CLOCKS_PER_SEC;
212  printf("%d trials in %f s -> %f trials per sec\n", trialCount, duration, trialCount / duration);
213  printf("%d tests per trial\n", testCount / trialCount);
214 }
JSON Schema Validator.
Definition: fwd.h:145
Here is the call graph for this function: