Skip to content

Commit 50c39e0

Browse files
committed
test results
1 parent b5a2767 commit 50c39e0

12 files changed

+83
-54
lines changed

docs/index.html

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,13 @@ <h2>JSON Test Suite</h2>
4444
<tr>
4545
<th></th>
4646
<th class="rotate"><div><span>jsoncons-master20180126</span></div></th>
47-
<th class="rotate"><div><span>nlohmann-2.0.7</span></div></th>
48-
<th class="rotate"><div><span>cJSON-master 20180125</span></div></th>
47+
<th class="rotate"><div><span>nlohmann-3.0.1</span></div></th>
48+
<th class="rotate"><div><span>cJSON-1.7.1</span></div></th>
49+
<th class="rotate"><div><span>json11-master 20161125</span></div></th>
50+
<th class="rotate"><div><span>rapidjson-1.1.0</span></div></th>
51+
<th class="rotate"><div><span>jsoncpp-1.7.7</span></div></th>
52+
<th class="rotate"><div><span>json_spirit-4.08</span></div></th>
53+
<th class="rotate"><div><span>gason-master 20161107</span></div></th>
4954

5055
</tr>
5156
<tr><td bgcolor="#d19b73"><font color="white">Expected result</font></td><td>283</td>
@@ -77,7 +82,7 @@ <h2>JSON Test Suite</h2>
7782
</tr>
7883
<tr><td bgcolor="#f7a8ff"><font color="white">Result undefined, parsing succeeded</font></td><td>17</td>
7984
<td>7</td>
80-
<td>20</td>
85+
<td>21</td>
8186
<td>30</td>
8287
<td>19</td>
8388
<td>26</td>
@@ -86,7 +91,7 @@ <h2>JSON Test Suite</h2>
8691
</tr>
8792
<tr><td bgcolor="#050f07"><font color="white">Result undefined, parsing failed</font></td><td>18</td>
8893
<td>28</td>
89-
<td>15</td>
94+
<td>14</td>
9095
<td>5</td>
9196
<td>16</td>
9297
<td>9</td>
@@ -112,6 +117,11 @@ <h2>JSON Test Suite</h2>
112117
<th class="rotate"><div><span>jsoncons</span></div></th>
113118
<th class="rotate"><div><span>nlohmann</span></div></th>
114119
<th class="rotate"><div><span>cJSON</span></div></th>
120+
<th class="rotate"><div><span>json11</span></div></th>
121+
<th class="rotate"><div><span>rapidjson</span></div></th>
122+
<th class="rotate"><div><span>jsoncpp</span></div></th>
123+
<th class="rotate"><div><span>json_spirit</span></div></th>
124+
<th class="rotate"><div><span>gason</span></div></th>
115125

116126
<th></th>
117127
</tr>
@@ -3616,7 +3626,7 @@ <h2>JSON Test Suite</h2>
36163626
<tr>
36173627
<td>i_structure_UTF-8_BOM_empty_object.json</td><td bgcolor="#f7a8ff"></td>
36183628
<td bgcolor="#f7a8ff"></td>
3619-
<td bgcolor="#050f07"></td>
3629+
<td bgcolor="#f7a8ff"></td>
36203630
<td bgcolor="#050f07"></td>
36213631
<td bgcolor="#050f07"></td>
36223632
<td bgcolor="#050f07"></td>
@@ -3634,8 +3644,13 @@ <h2>JSON Checker</h2>
36343644
<tr>
36353645
<th></th>
36363646
<th class="rotate"><div><span>jsoncons-master20180126</span></div></th>
3637-
<th class="rotate"><div><span>nlohmann-2.0.7</span></div></th>
3638-
<th class="rotate"><div><span>cJSON-master 20180125</span></div></th>
3647+
<th class="rotate"><div><span>nlohmann-3.0.1</span></div></th>
3648+
<th class="rotate"><div><span>cJSON-1.7.1</span></div></th>
3649+
<th class="rotate"><div><span>json11-master 20161125</span></div></th>
3650+
<th class="rotate"><div><span>rapidjson-1.1.0</span></div></th>
3651+
<th class="rotate"><div><span>jsoncpp-1.7.7</span></div></th>
3652+
<th class="rotate"><div><span>json_spirit-4.08</span></div></th>
3653+
<th class="rotate"><div><span>gason-master 20161107</span></div></th>
36393654

36403655
</tr>
36413656
<tr><td bgcolor="#d19b73"><font color="white">Expected result</font></td><td>34</td>
@@ -3702,6 +3717,11 @@ <h2>JSON Checker</h2>
37023717
<th class="rotate"><div><span>jsoncons</span></div></th>
37033718
<th class="rotate"><div><span>nlohmann</span></div></th>
37043719
<th class="rotate"><div><span>cJSON</span></div></th>
3720+
<th class="rotate"><div><span>json11</span></div></th>
3721+
<th class="rotate"><div><span>rapidjson</span></div></th>
3722+
<th class="rotate"><div><span>jsoncpp</span></div></th>
3723+
<th class="rotate"><div><span>json_spirit</span></div></th>
3724+
<th class="rotate"><div><span>gason</span></div></th>
37053725

37063726
<th></th>
37073727
</tr>

parsers/rapidjson/rapidjson_parser.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <fstream>
2+
#include <vector>
23
#include "rapidjson/document.h"
34
#include "rapidjson/writer.h"
45
#include "rapidjson/filereadstream.h"
@@ -16,8 +17,9 @@ int main(int argc, char *argv[])
1617
{
1718
Document doc;
1819
FILE* fp = fopen(argv[1], "rb"); // non-Windows use "r"
19-
char readBuffer[65536];
20-
FileReadStream is(fp, readBuffer, sizeof(readBuffer));
20+
std::vector<char> readBuffer;
21+
readBuffer.resize(65536);
22+
FileReadStream is(fp, readBuffer.data(), readBuffer.size());
2123
ParseResult ok = doc.ParseStream(is);
2224
if (!ok)
2325
{

report/performance.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Input filename|Size (MB)|Content
66
---|---|---
7-
data/input/persons.json|610.65|Text,integers
7+
data/output/persons.json|610.65|Text,integers
88

99
Environment|Windows, Intel
1010
---|---
@@ -15,17 +15,22 @@ Compiler|Visual Studio 2015
1515
Library|Version
1616
---|---
1717
[jsoncons](https://github.com/danielaparker/jsoncons)|master20180126
18-
[nlohmann](https://github.com/nlohmann/json)|2.0.7
19-
[cJSON](https://github.com/DaveGamble/cJSON)|master 20180125
18+
[nlohmann](https://github.com/nlohmann/json)|3.0.1
19+
[cJSON](https://github.com/DaveGamble/cJSON)|1.7.1
20+
[json11](https://github.com/dropbox/json11)|master 20161125
21+
[rapidjson](https://github.com/miloyip/rapidjson)|1.1.0
22+
[jsoncpp](https://github.com/open-source-parsers/jsoncpp)|1.7.7
23+
[json_spirit](http://www.codeproject.com/Articles/20027/JSON-Spirit-A-C-JSON-Parser-Generator-Implemented))|4.08
24+
[gason](https://github.com/vivkin/gason)|master 20161107
2025

2126
Library|Time to read (s)|Time to write (s)|Memory footprint of json value (MB)|Remarks
2227
---|---|---|---|---
23-
[jsoncons](https://github.com/danielaparker/jsoncons)|10.153|3.039|2067|
24-
[nlohmann](https://github.com/nlohmann/json)|19.057|13.924|2292|
25-
[cjson](https://github.com/DaveGamble/cJSON)|24.399|71.392|11111|
26-
[json11](https://github.com/dropbox/json11)|24.871|16.143|9297|
27-
[rapidjson](https://github.com/miloyip/rapidjson)|8.638|2.491|3739|
28-
[jsoncpp](https://github.com/open-source-parsers/jsoncpp)|77.573|42.039|12551|
29-
[json_spirit](http://www.codeproject.com/Articles/20027/JSON-Spirit-A-C-JSON-Parser-Generator-Implemented)|382.213|60.362|5188|Boost spirit parsing is slow
30-
[gason](https://github.com/vivkin/gason)|9.102|86.714|2949|No serialization function, using sample pretty-print code
28+
[jsoncons](https://github.com/danielaparker/jsoncons)|10.053|3.494|2067|
29+
[nlohmann](https://github.com/nlohmann/json)|18.12|13.733|2292|
30+
[cjson](https://github.com/DaveGamble/cJSON)|19.499|66.15|11111|
31+
[json11](https://github.com/dropbox/json11)|27.418|14.67|9305|
32+
[rapidjson](https://github.com/miloyip/rapidjson)|8.462|2.592|3747|
33+
[jsoncpp](https://github.com/open-source-parsers/jsoncpp)|66.301|20.487|12427|
34+
[json_spirit](http://www.codeproject.com/Articles/20027/JSON-Spirit-A-C-JSON-Parser-Generator-Implemented)|333.143|54.467|4988|Boost spirit parsing is slow
35+
[gason](https://github.com/vivkin/gason)|7.68|79.401|2987|No serialization function, using sample pretty-print code
3136

report/performance_fp.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Input filename|Size (MB)|Content
66
---|---|---
7-
data/input/persons_fp.json|1207.9|Text,integers
7+
data/output/persons_fp.json|595.4|Text,integers
88

99
Environment|Windows, Intel
1010
---|---
@@ -15,17 +15,22 @@ Compiler|Visual Studio 2015
1515
Library|Version
1616
---|---
1717
[jsoncons](https://github.com/danielaparker/jsoncons)|master20180126
18-
[nlohmann](https://github.com/nlohmann/json)|2.0.7
19-
[cJSON](https://github.com/DaveGamble/cJSON)|master 20180125
18+
[nlohmann](https://github.com/nlohmann/json)|3.0.1
19+
[cJSON](https://github.com/DaveGamble/cJSON)|1.7.1
20+
[json11](https://github.com/dropbox/json11)|master 20161125
21+
[rapidjson](https://github.com/miloyip/rapidjson)|1.1.0
22+
[jsoncpp](https://github.com/open-source-parsers/jsoncpp)|1.7.7
23+
[json_spirit](http://www.codeproject.com/Articles/20027/JSON-Spirit-A-C-JSON-Parser-Generator-Implemented))|4.08
24+
[gason](https://github.com/vivkin/gason)|master 20161107
2025

2126
Library|Time to read (s)|Time to write (s)|Memory footprint of json value (MB)|Remarks
2227
---|---|---|---|---
23-
[jsoncons](https://github.com/danielaparker/jsoncons)|36.323|49.891|1701|
24-
[nlohmann](https://github.com/nlohmann/json)|49.952|30.858|186|
25-
[cjson](https://github.com/DaveGamble/cJSON)|69.822|105.128|11238|
26-
[json11](https://github.com/dropbox/json11)|68.701|68.608|9625|
27-
[rapidjson](https://github.com/miloyip/rapidjson)|29.322|13.698|3807|
28-
[jsoncpp](https://github.com/open-source-parsers/jsoncpp)|148.824|117.22|12542|
29-
[json_spirit](http://www.codeproject.com/Articles/20027/JSON-Spirit-A-C-JSON-Parser-Generator-Implemented)|623.045|126.12|6280|Boost spirit parsing is slow
30-
[gason](https://github.com/vivkin/gason)|14.727|88.317|3314|No serialization function, using sample pretty-print code
28+
[jsoncons](https://github.com/danielaparker/jsoncons)|16.505|24.256|309|
29+
[nlohmann](https://github.com/nlohmann/json)|26.152|30.162|0|
30+
[cjson](https://github.com/DaveGamble/cJSON)|30.806|43.142|5641|
31+
[json11](https://github.com/dropbox/json11)|29.638|31.187|5155|
32+
[rapidjson](https://github.com/miloyip/rapidjson)|14.567|5.202|1683|
33+
[jsoncpp](https://github.com/open-source-parsers/jsoncpp)|60.838|47.272|5331|
34+
[json_spirit](http://www.codeproject.com/Articles/20027/JSON-Spirit-A-C-JSON-Parser-Generator-Implemented)|345.284|62.109|3464|Boost spirit parsing is slow
35+
[gason](https://github.com/vivkin/gason)|5.631|41.655|1472|No serialization function, using sample pretty-print code
3136

src/test_driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void benchmarks_fp()
8282
library_tests tests;
8383

8484
const char *filename = "data/output/persons_fp.json";
85-
make_big_file(filename, 50000, 0, 5000, 0);
85+
make_big_file(filename, 50000, 0, 2500, 0);
8686

8787
size_t file_size;
8888
{

src/tests/cjson_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ measurements measure_cjson(const char *input_filename,
6767
// perror(output_filename);
6868
// exit(EXIT_FAILURE);
6969
//}
70-
char* s = cJSON_Print(root);
70+
char* s = cJSON_PrintUnformatted(root);
7171
std::ofstream os; //(output_filename/*,std::ofstream::binary*/);
7272
//os.rdbuf()->pubsetbuf(writeBuffer, sizeof(writeBuffer));
7373
os.open(output_filename, std::ios_base::out | std::ios_base::binary);

src/tests/json11_tests.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ measurements measure_json11(const char *input_filename,
6161

6262
std::string s;
6363
val.dump(s);
64-
//char writeBuffer[65536];
65-
std::ofstream os; //(output_filename/*,std::ofstream::binary*/);
66-
//os.rdbuf()->pubsetbuf(writeBuffer, sizeof(writeBuffer));
64+
std::ofstream os;
6765
os.open(output_filename, std::ios_base::out | std::ios_base::binary);
6866
os << s;
6967

src/tests/json_spirit_tests.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ measurements measure_json_spirit(const char *input_filename,
5050
}
5151
end_memory_used = memory_measurer::virtual_memory_currently_used_by_current_process();
5252
{
53-
//char writeBuffer[65536];
54-
std::ofstream os; //(output_filename/*,std::ofstream::binary*/);
55-
//os.rdbuf()->pubsetbuf(writeBuffer, sizeof(writeBuffer));
53+
std::ofstream os;
5654
os.open(output_filename, std::ios_base::out | std::ios_base::binary);
5755
auto start = high_resolution_clock::now();
5856
write_stream(root,os);

src/tests/jsoncons_tests.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ measurements measure_jsoncons(const char *input_filename,
4747
}
4848
end_memory_used = memory_measurer::virtual_memory_currently_used_by_current_process();
4949
{
50-
//char writeBuffer[65536];
51-
std::ofstream os; //(output_filename/*,std::ofstream::binary*/);
52-
//os.rdbuf()->pubsetbuf(writeBuffer, sizeof(writeBuffer));
50+
std::ofstream os;
5351
os.open(output_filename, std::ios_base::out | std::ios_base::binary);
5452
auto start = high_resolution_clock::now();
5553
os << root;

src/tests/jsoncpp_tests.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,18 @@ measurements measure_jsoncpp(const char *input_filename,
5151
}
5252
end_memory_used = memory_measurer::virtual_memory_currently_used_by_current_process();
5353
{
54-
char writeBuffer[65536];
55-
std::ofstream os; //(output_filename/*,std::ofstream::binary*/);
56-
os.rdbuf()->pubsetbuf(writeBuffer, sizeof(writeBuffer));
54+
std::ofstream os;
5755
os.open(output_filename, std::ios_base::out | std::ios_base::binary);
5856
auto start = high_resolution_clock::now();
5957
//os << root;
6058

61-
StyledWriter styledWriter;
59+
60+
Json::FastWriter writer;
61+
os << writer.write( root );
62+
63+
//StyledWriter styledWriter;
6264
//std::ofstream writer(filename, std::ifstream::binary);
63-
os << styledWriter.write(root);
65+
//os << styledWriter.write(root);
6466

6567
auto end = high_resolution_clock::now();
6668
time_to_write = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();

src/tests/nlohmann_tests.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ measurements measure_nlohmann(const char *input_filename,
4545
}
4646
end_memory_used = memory_measurer::virtual_memory_currently_used_by_current_process();
4747
{
48-
char writeBuffer[65536];
49-
std::ofstream os; //(output_filename/*,std::ofstream::binary*/);
50-
os.rdbuf()->pubsetbuf(writeBuffer, sizeof(writeBuffer));
48+
std::ofstream os;
5149
os.open(output_filename, std::ios_base::out | std::ios_base::binary);
5250
auto start = high_resolution_clock::now();
5351
os << root;

src/tests/rapidjson_tests.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <fstream>
88
#include <iostream>
99
#include <cassert>
10+
#include <vector>
1011
#include <boost/filesystem.hpp>
1112
#include "../measurements.hpp"
1213
#include "../memory_measurer.hpp"
@@ -37,8 +38,9 @@ measurements measure_rapidjson(const char *input_filename,
3738
{
3839
auto start = high_resolution_clock::now();
3940
FILE* fp = fopen(input_filename, "rb"); // non-Windows use "r"
40-
char readBuffer[65536];
41-
FileReadStream is(fp, readBuffer, sizeof(readBuffer));
41+
std::vector<char> readBuffer;
42+
readBuffer.resize(65536);
43+
FileReadStream is(fp, readBuffer.data(), readBuffer.size());
4244
d.ParseStream(is);
4345
auto end = high_resolution_clock::now();
4446
time_to_read = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
@@ -56,8 +58,9 @@ measurements measure_rapidjson(const char *input_filename,
5658
FILE* fp = fopen(output_filename, "wb"); // non-Windows use "w"
5759
assert(fp != nullptr);
5860

59-
char writeBuffer[65536];
60-
FileWriteStream os(fp, writeBuffer, sizeof(writeBuffer));
61+
std::vector<char> writeBuffer;
62+
writeBuffer.resize(65536);
63+
FileWriteStream os(fp, &writeBuffer[0], writeBuffer.size());
6164

6265
Writer<FileWriteStream> writer(os);
6366
auto start = high_resolution_clock::now();

0 commit comments

Comments
 (0)