Fix schema performance stats
This commit is contained in:
parent
b8a273705e
commit
28f11ac429
@ -221,7 +221,7 @@ On a Mac Book Pro (2.8 GHz Intel Core i7), the following results are collected.
|
||||
|
||||
|Validator|Relative speed|Number of test runs per second|
|
||||
|---------|:------------:|:----------------------------:|
|
||||
|RapidJSON|36521%|7220217|
|
||||
|RapidJSON|155%|30682|
|
||||
|[`ajv`](https://github.com/epoberezkin/ajv)|100%|19770 (± 1.31%)|
|
||||
|[`is-my-json-valid`](https://github.com/mafintosh/is-my-json-valid)|70%|13835 (± 2.84%)|
|
||||
|[`jsen`](https://github.com/bugventure/jsen)|57.7%|11411 (± 1.27%)|
|
||||
@ -234,4 +234,4 @@ On a Mac Book Pro (2.8 GHz Intel Core i7), the following results are collected.
|
||||
|tv4|0.5%|93 (± 0.94%)|
|
||||
|[`jayschema`](https://github.com/natesilva/jayschema)|0.1%|21 (± 1.14%)|
|
||||
|
||||
That is, RapidJSON is about ~365 times faster than the fastest JavaScript library (ajv). And ~344 thousand times faster than the slowest one.
|
||||
That is, RapidJSON is about 1.5x faster than the fastest JavaScript library (ajv). And 1400x faster than the slowest one.
|
||||
|
@ -221,7 +221,7 @@ RapidJSON 实现了一个简单的 NFA 正则表达式引擎,并预设使用
|
||||
|
||||
|校验器|相对速度|每秒执行的测试数目|
|
||||
|---------|:------------:|:----------------------------:|
|
||||
|RapidJSON|36521%|7220217|
|
||||
|RapidJSON|155%|30682|
|
||||
|[`ajv`](https://github.com/epoberezkin/ajv)|100%|19770 (± 1.31%)|
|
||||
|[`is-my-json-valid`](https://github.com/mafintosh/is-my-json-valid)|70%|13835 (± 2.84%)|
|
||||
|[`jsen`](https://github.com/bugventure/jsen)|57.7%|11411 (± 1.27%)|
|
||||
@ -234,4 +234,4 @@ RapidJSON 实现了一个简单的 NFA 正则表达式引擎,并预设使用
|
||||
|tv4|0.5%|93 (± 0.94%)|
|
||||
|[`jayschema`](https://github.com/natesilva/jayschema)|0.1%|21 (± 1.14%)|
|
||||
|
||||
换言之,RapidJSON 比最快的 JavaScript 库(ajv)快约 365 倍。比最慢的快 34 万倍。
|
||||
换言之,RapidJSON 比最快的 JavaScript 库(ajv)快约 1.5x。比最慢的快 1400x。
|
||||
|
@ -100,7 +100,8 @@ public:
|
||||
}
|
||||
|
||||
for (Value::ConstValueIterator schemaItr = d.Begin(); schemaItr != d.End(); ++schemaItr) {
|
||||
if (IsExcludeTestSuite((*schemaItr)["description"].GetString()))
|
||||
std::string schemaDescription = (*schemaItr)["description"].GetString();
|
||||
if (IsExcludeTestSuite(schemaDescription))
|
||||
continue;
|
||||
|
||||
TestSuite* ts = new TestSuite;
|
||||
@ -108,7 +109,7 @@ public:
|
||||
|
||||
const Value& tests = (*schemaItr)["tests"];
|
||||
for (Value::ConstValueIterator testItr = tests.Begin(); testItr != tests.End(); ++testItr) {
|
||||
if (IsExcludeTest((*testItr)["description"].GetString()))
|
||||
if (IsExcludeTest(schemaDescription + ", " + (*testItr)["description"].GetString()))
|
||||
continue;
|
||||
|
||||
Document* d2 = new Document;
|
||||
@ -191,9 +192,10 @@ TEST_F(Schema, TestSuite) {
|
||||
char validatorBuffer[65536];
|
||||
MemoryPoolAllocator<> validatorAllocator(validatorBuffer, sizeof(validatorBuffer));
|
||||
|
||||
const int trialCount = 100000;
|
||||
int testCount = 0;
|
||||
clock_t start = clock();
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
for (int i = 0; i < trialCount; i++) {
|
||||
for (TestSuiteList::const_iterator itr = testSuites.begin(); itr != testSuites.end(); ++itr) {
|
||||
const TestSuite& ts = **itr;
|
||||
GenericSchemaValidator<SchemaDocument, BaseReaderHandler<UTF8<> >, MemoryPoolAllocator<> > validator(*ts.schema, &validatorAllocator);
|
||||
@ -207,7 +209,8 @@ TEST_F(Schema, TestSuite) {
|
||||
}
|
||||
clock_t end = clock();
|
||||
double duration = double(end - start) / CLOCKS_PER_SEC;
|
||||
printf("%d tests in %f s -> %f tests per sec\n", testCount, duration, testCount / duration);
|
||||
printf("%d trials in %f s -> %f trials per sec\n", trialCount, duration, trialCount / duration);
|
||||
printf("%d tests per trial\n", testCount / trialCount);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user