Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
10bad938
Unverified
Commit
10bad938
authored
Jan 10, 2018
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🚧
added size benchmark for binary formats
parent
3a7585e7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
1 deletion
+39
-1
Makefile
benchmarks/Makefile
+4
-1
formats.cpp
benchmarks/src/formats.cpp
+35
-0
No files found.
benchmarks/Makefile
View file @
10bad938
...
@@ -17,5 +17,8 @@ json_benchmarks_simple: src/benchmarks_simple.cpp ../src/json.hpp
...
@@ -17,5 +17,8 @@ json_benchmarks_simple: src/benchmarks_simple.cpp ../src/json.hpp
number_jsons
:
number_jsons
:
(
test
-e
files/numbers/floats.json
-a
-e
files/numbers/signed_ints.json
-a
-e
files/numbers/unsigned_ints.json
)
||
(
cd
files/numbers
;
python generate.py
)
(
test
-e
files/numbers/floats.json
-a
-e
files/numbers/signed_ints.json
-a
-e
files/numbers/unsigned_ints.json
)
||
(
cd
files/numbers
;
python generate.py
)
json_formats
:
src/formats.cpp ../src/json.hpp number_jsons
$(CXX)
-std
=
c++11
$(CXXFLAGS)
-DNDEBUG
-O3
-flto
-I
../src
$
(
<
)
$(LDFLAGS)
-o
$@
clean
:
clean
:
rm
-f
json_benchmarks json_benchmarks_simple
files/numbers/
*
.json
rm
-f
json_benchmarks json_benchmarks_simple
json_formats files/numbers/
*
.json
benchmarks/src/formats.cpp
0 → 100644
View file @
10bad938
#include <json.hpp>
#include <fstream>
#include <iostream>
using
json
=
nlohmann
::
json
;
int
main
()
{
std
::
vector
<
std
::
string
>
files
=
{
"files/jeopardy/jeopardy.json"
,
"files/nativejson-benchmark/canada.json"
,
"files/nativejson-benchmark/citm_catalog.json"
,
"files/nativejson-benchmark/twitter.json"
,
"files/numbers/floats.json"
,
"files/numbers/signed_ints.json"
,
"files/numbers/unsigned_ints.json"
};
for
(
const
auto
&
file
:
files
)
{
std
::
ifstream
f
(
file
);
json
j
=
json
::
parse
(
f
);
auto
v_cbor
=
json
::
to_cbor
(
j
);
auto
v_msgpack
=
json
::
to_msgpack
(
j
);
auto
v_ubjson
=
json
::
to_ubjson
(
j
,
true
,
true
);
double
baseline
=
j
.
dump
().
size
();
std
::
cout
<<
file
<<
", JSON: "
<<
j
.
dump
(
2
).
size
()
<<
" "
<<
j
.
dump
(
2
).
size
()
/
baseline
<<
std
::
endl
;
std
::
cout
<<
file
<<
", JSON (minified): "
<<
j
.
dump
().
size
()
<<
std
::
endl
;
std
::
cout
<<
file
<<
", CBOR: "
<<
v_cbor
.
size
()
<<
" "
<<
v_cbor
.
size
()
/
baseline
<<
std
::
endl
;
std
::
cout
<<
file
<<
", MessagePack: "
<<
v_msgpack
.
size
()
<<
" "
<<
v_msgpack
.
size
()
/
baseline
<<
std
::
endl
;
std
::
cout
<<
file
<<
", UBJSON (optimized): "
<<
v_ubjson
.
size
()
<<
" "
<<
v_ubjson
.
size
()
/
baseline
<<
std
::
endl
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment