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
4c98c971
Commit
4c98c971
authored
Jul 20, 2016
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added benchmarks for numbers
parent
1286d357
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
0 deletions
+59
-0
.gitignore
.gitignore
+2
-0
Makefile
Makefile
+2
-0
benchmarks.cpp
benchmarks/benchmarks.cpp
+30
-0
generate.py
benchmarks/files/numbers/generate.py
+25
-0
No files found.
.gitignore
View file @
4c98c971
...
@@ -12,3 +12,5 @@ me.nlohmann.json.docset
...
@@ -12,3 +12,5 @@ me.nlohmann.json.docset
android
android
doc/xml
doc/xml
benchmarks/files/numbers/*.json
Makefile
View file @
4c98c971
...
@@ -10,6 +10,7 @@ all: json_unit
...
@@ -10,6 +10,7 @@ all: json_unit
# clean up
# clean up
clean
:
clean
:
rm
-fr
json_unit json_benchmarks fuzz fuzz-testing
*
.dSYM
rm
-fr
json_unit json_benchmarks fuzz fuzz-testing
*
.dSYM
rm
-fr
benchmarks/files/numbers/
*
.json
$(MAKE)
clean
-Cdoc
$(MAKE)
clean
-Cdoc
...
@@ -85,6 +86,7 @@ pretty:
...
@@ -85,6 +86,7 @@ pretty:
# benchmarks
# benchmarks
json_benchmarks
:
benchmarks/benchmarks.cpp benchmarks/benchpress.hpp benchmarks/cxxopts.hpp src/json.hpp
json_benchmarks
:
benchmarks/benchmarks.cpp benchmarks/benchpress.hpp benchmarks/cxxopts.hpp src/json.hpp
cd
benchmarks/files/numbers
;
python generate.py
$(CXX)
-std
=
c++11
$(CXXFLAGS)
-O3
-flto
-I
src
-I
benchmarks
$<
$(LDFLAGS)
-o
$@
$(CXX)
-std
=
c++11
$(CXXFLAGS)
-O3
-flto
-I
src
-I
benchmarks
$<
$(LDFLAGS)
-o
$@
./json_benchmarks
./json_benchmarks
...
...
benchmarks/benchmarks.cpp
View file @
4c98c971
...
@@ -44,6 +44,36 @@ BENCHMARK("parse twitter.json", [](benchpress::context* ctx)
...
@@ -44,6 +44,36 @@ BENCHMARK("parse twitter.json", [](benchpress::context* ctx)
}
}
})
})
BENCHMARK
(
"parse numbers/floats.json"
,
[](
benchpress
::
context
*
ctx
)
{
for
(
size_t
i
=
0
;
i
<
ctx
->
num_iterations
();
++
i
)
{
std
::
ifstream
input_file
(
"benchmarks/files/numbers/floats.json"
);
nlohmann
::
json
j
;
j
<<
input_file
;
}
})
BENCHMARK
(
"parse numbers/signed_ints.json"
,
[](
benchpress
::
context
*
ctx
)
{
for
(
size_t
i
=
0
;
i
<
ctx
->
num_iterations
();
++
i
)
{
std
::
ifstream
input_file
(
"benchmarks/files/numbers/signed_ints.json"
);
nlohmann
::
json
j
;
j
<<
input_file
;
}
})
BENCHMARK
(
"parse numbers/unsigned_ints.json"
,
[](
benchpress
::
context
*
ctx
)
{
for
(
size_t
i
=
0
;
i
<
ctx
->
num_iterations
();
++
i
)
{
std
::
ifstream
input_file
(
"benchmarks/files/numbers/unsigned_ints.json"
);
nlohmann
::
json
j
;
j
<<
input_file
;
}
})
BENCHMARK
(
"dump jeopardy.json"
,
[](
benchpress
::
context
*
ctx
)
BENCHMARK
(
"dump jeopardy.json"
,
[](
benchpress
::
context
*
ctx
)
{
{
std
::
ifstream
input_file
(
"benchmarks/files/jeopardy/jeopardy.json"
);
std
::
ifstream
input_file
(
"benchmarks/files/jeopardy/jeopardy.json"
);
...
...
benchmarks/files/numbers/generate.py
0 → 100755
View file @
4c98c971
#!/usr/bin/env python
import
json
import
random
import
sys
random
.
seed
(
0
)
# floats
result_floats
=
[]
for
x
in
range
(
0
,
1000000
):
result_floats
.
append
(
random
.
uniform
(
-
100000000.0
,
100000000.0
))
json
.
dump
(
result_floats
,
open
(
"floats.json"
,
"w"
),
indent
=
2
)
# unsigned integers
result_uints
=
[]
for
x
in
range
(
0
,
1000000
):
result_uints
.
append
(
random
.
randint
(
0
,
18446744073709551615
))
json
.
dump
(
result_uints
,
open
(
"unsigned_ints.json"
,
"w"
),
indent
=
2
)
# signed integers
result_sints
=
[]
for
x
in
range
(
0
,
1000000
):
result_sints
.
append
(
random
.
randint
(
-
9223372036854775808
,
9223372036854775807
))
json
.
dump
(
result_sints
,
open
(
"signed_ints.json"
,
"w"
),
indent
=
2
)
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