Merge branch 'master' of github.com:lemire/simdjson

This commit is contained in:
Daniel Lemire 2019-01-24 14:29:02 -05:00
commit 35eceaf1c4
43 changed files with 8447 additions and 72 deletions

3
.gitmodules vendored
View File

@ -22,3 +22,6 @@
[submodule "dependencies/cJSON"]
path = dependencies/cJSON
url = https://github.com/DaveGamble/cJSON.git
[submodule "dependencies/jsoncpp"]
path = dependencies/jsoncpp
url = https://github.com/open-source-parsers/jsoncpp.git

View File

@ -6,7 +6,7 @@
.PHONY: clean cleandist
COREDEPSINCLUDE = -Idependencies/rapidjson/include -Idependencies/sajson/include -Idependencies/cJSON -Idependencies/jsmn
EXTRADEPSINCLUDE = -Idependencies/json11 -Idependencies/fastjson/src -Idependencies/fastjson/include -Idependencies/gason/src -Idependencies/ujson4c/3rdparty -Idependencies/ujson4c/src
EXTRADEPSINCLUDE = -Idependencies/jsoncppdist -Idependencies/json11 -Idependencies/fastjson/src -Idependencies/fastjson/include -Idependencies/gason/src -Idependencies/ujson4c/3rdparty -Idependencies/ujson4c/src
CXXFLAGS = -std=c++17 -march=native -Wall -Wextra -Wshadow -Iinclude -Ibenchmark/linux
CFLAGS = -march=native -Idependencies/ujson4c/3rdparty -Idependencies/ujson4c/src
ifeq ($(SANITIZE),1)
@ -42,6 +42,7 @@ UJSON4C_INCLUDE:=dependencies/ujson4c/src/ujdecode.c
CJSON_INCLUDE:=dependencies/cJSON/cJSON.h
JSMN_INCLUDE:=dependencies/jsmn/jsmn.h
LIBS=$(RAPIDJSON_INCLUDE) $(SAJSON_INCLUDE) $(JSON11_INCLUDE) $(FASTJSON_INCLUDE) $(GASON_INCLUDE) $(UJSON4C_INCLUDE) $(CJSON_INCLUDE) $(JSMN_INCLUDE)
EXTRAOBJECTS=ujdecode.o

View File

@ -12,26 +12,27 @@ We can use a quarter or fewer instructions than a state-of-the-art parser like R
<img src="doc/gbps.png" width="90%">
Next we present the time (in cycles per input byte) needed to fully parse a JSON file (with error checking) and to collect some statistics about the document (e.g., the number of integers), for some JSON files. For these tests, we use an Intel processor with a Skylake microarchitecture. All results are single-threaded. *Lower results are better.*
github_events.json:
<img src="doc/github_events.jsonparseandstat.png" width="50%">
twitter.json:
<img src="doc/twitter.jsonparseandstat.png" width="50%">
On a skylake processor, the parsing speeds (in GB/s) of various processors on the twitter.json file are as follows.
| parser | GB/s |
|---|---|
| simdjson | 2.2 |
| RapidJSON encoding-validation | 0.51|
| RapidJSON encoding-validation, insitu | 0.71|
| sajson (insitu, dynamic) | 0.70|
| sajson (insitu, static) | 0.97|
| dropbox | 0.14|
| fastjson | 0.26|
| gason | 0.85|
| ultrajson | 0.42|
| jsmn | 0.28|
|cJSON | 0.34|
## Requirements
- We support platforms like Linux or macOS, as well as Windows through Visual Studio 2017 or better.
- A processor with AVX2 (i.e., Intel processors starting with the Haswell microarchitecture released 2013, and processors from AMD starting with the Rizen)
- A recent C++ compiler (e.g., GNU GCC or LLVM CLANG or Visual Studio 2017), we assume C++17
- A recent C++ compiler (e.g., GNU GCC or LLVM CLANG or Visual Studio 2017), we assume C++17. GNU GCC 7 or better or LLVM's clang 6 or better.
- Some benchmark scripts assume bash and other common utilities, but they are optional.
## License
@ -84,7 +85,7 @@ See the "singleheader" repository for a single header version. See the included
file "amalgamation_demo.cpp" for usage. This requires no specific build system: just
copy the files in your project in your include path. You can then include them quite simply:
```
```C
#include <iostream>
#include "simdjson.h"
#include "simdjson.cpp"
@ -105,7 +106,7 @@ Note: In some settings, it might be desirable to precompile `simdjson.cpp` inste
## Usage (old-school Makefile on platforms like Linux or macOS)
Requirements: recent clang or gcc, and make. We recommend at least GNU GCC/G++ 7. A system like Linux or macOS is expected.
Requirements: recent clang or gcc, and make. We recommend at least GNU GCC/G++ 7 or LLVM clang 6. A system like Linux or macOS is expected.
To test:
@ -130,11 +131,25 @@ make benchmark
## Usage (CMake on platforms like Linux or macOS)
Requirements: You need a recent compiler like clang or gcc. We recommend at least GNU GCC/G++ 7.
Requirements: We require a recent version of cmake. On macOS, the easiest way to install cmake might be to use [brew](https://brew.sh) and then type
We require a recent version of cmake. On macOS, the easiest way to install cmake might be to use [brew](https://brew.sh) and then type "brew install cmake". There is an [equivalent brew on Linux which works the same way as well](https://linuxbrew.sh).
```
brew install cmake"
```
While in the project repository, do the following:
There is an [equivalent brew on Linux which works the same way as well](https://linuxbrew.sh).
You need a recent compiler like clang or gcc. We recommend at least GNU GCC/G++ 7 or LLVM clang 6. For example, you can install a recent compiler with brew:
```
brew install gcc@8
```
Optional: You need to tell cmake which compiler you wish to use by setting the CC and CXX variables. Under bash, you can do so with commands such as ``export CC=gcc-7`` and ``export CXX=g++-7``.
Building: While in the project repository, do the following:
```
mkdir build

View File

@ -20,9 +20,12 @@
#include "sajson.h"
#ifdef ALLPARSER
#include "fastjson.cpp"
#include "fastjson_dom.cpp"
#include "gason.cpp"
#include "json11.cpp"
extern "C" {
#include "ujdecode.h"
@ -32,6 +35,10 @@ extern "C" {
#include "jsmn.h"
#include "jsmn.c"
}
#include "json/json.h"
#include "jsoncpp.cpp"
#endif
using namespace rapidjson;
@ -238,7 +245,16 @@ int main(int argc, char *argv[]) {
BEST_TIME("cJSON ",
((tree = cJSON_Parse(buffer)) != NULL ), true,
cJSON_Delete(tree), repeat, volume, !justdata);
cJSON_Delete(tree);
cJSON_Delete(tree);
Json::CharReaderBuilder b;
Json::CharReader * jsoncppreader = b.newCharReader();
Json::Value root;
Json::String errs;
BEST_TIME("jsoncpp ",
jsoncppreader->parse(buffer,buffer+volume,&root,&errs), true,
, repeat, volume, !justdata);
delete jsoncppreader;
#endif
if(!justdata) BEST_TIME("memcpy ",
(memcpy(buffer, p.data(), p.size()) == buffer), true, , repeat,

1
dependencies/jsoncpp vendored Submodule

@ -0,0 +1 @@
Subproject commit 0c1cc6e1a373dc58e2599ec7dd68b2e6b863990a

View File

@ -0,0 +1,344 @@
/// Json-cpp amalgamated forward header (http://jsoncpp.sourceforge.net/).
/// It is intended to be used with #include "json/json-forwards.h"
/// This header provides forward declaration for all JsonCpp types.
// //////////////////////////////////////////////////////////////////////
// Beginning of content of file: LICENSE
// //////////////////////////////////////////////////////////////////////
/*
The JsonCpp library's source code, including accompanying documentation,
tests and demonstration applications, are licensed under the following
conditions...
Baptiste Lepilleur and The JsonCpp Authors explicitly disclaim copyright in all
jurisdictions which recognize such a disclaimer. In such jurisdictions,
this software is released into the Public Domain.
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur and
The JsonCpp Authors, and is released under the terms of the MIT License (see below).
In jurisdictions which recognize Public Domain property, the user of this
software may choose to accept it either as 1) Public Domain, 2) under the
conditions of the MIT License (see below), or 3) under the terms of dual
Public Domain/MIT License conditions described here, as they choose.
The MIT License is about as close to Public Domain as a license can get, and is
described in clear, concise terms at:
http://en.wikipedia.org/wiki/MIT_License
The full text of the MIT License follows:
========================================================================
Copyright (c) 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
========================================================================
(END LICENSE TEXT)
The MIT license is compatible with both the GPL and commercial
software, affording one all of the rights of Public Domain with the
minor nuisance of being required to keep the above copyright notice
and license text in the source code. Note also that by accepting the
Public Domain "license" you can re-license your copy using whatever
license you like.
*/
// //////////////////////////////////////////////////////////////////////
// End of content of file: LICENSE
// //////////////////////////////////////////////////////////////////////
#ifndef JSON_FORWARD_AMALGAMATED_H_INCLUDED
# define JSON_FORWARD_AMALGAMATED_H_INCLUDED
/// If defined, indicates that the source file is amalgamated
/// to prevent private header inclusion.
#define JSON_IS_AMALGAMATION
// //////////////////////////////////////////////////////////////////////
// Beginning of content of file: include/json/config.h
// //////////////////////////////////////////////////////////////////////
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#ifndef JSON_CONFIG_H_INCLUDED
#define JSON_CONFIG_H_INCLUDED
#include <cstddef>
#include <cstdint>
#include <istream>
#include <memory>
#include <ostream>
#include <sstream>
#include <string>
#include <type_traits>
/// If defined, indicates that json library is embedded in CppTL library.
//# define JSON_IN_CPPTL 1
/// If defined, indicates that json may leverage CppTL library
//# define JSON_USE_CPPTL 1
/// If defined, indicates that cpptl vector based map should be used instead of
/// std::map
/// as Value container.
//# define JSON_USE_CPPTL_SMALLMAP 1
// If non-zero, the library uses exceptions to report bad input instead of C
// assertion macros. The default is to use exceptions.
#ifndef JSON_USE_EXCEPTION
#define JSON_USE_EXCEPTION 1
#endif
/// If defined, indicates that the source file is amalgamated
/// to prevent private header inclusion.
/// Remarks: it is automatically defined in the generated amalgamated header.
// #define JSON_IS_AMALGAMATION
#ifdef JSON_IN_CPPTL
#include <cpptl/config.h>
#ifndef JSON_USE_CPPTL
#define JSON_USE_CPPTL 1
#endif
#endif
#ifdef JSON_IN_CPPTL
#define JSON_API CPPTL_API
#elif defined(JSON_DLL_BUILD)
#if defined(_MSC_VER) || defined(__MINGW32__)
#define JSON_API __declspec(dllexport)
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
#endif // if defined(_MSC_VER)
#elif defined(JSON_DLL)
#if defined(_MSC_VER) || defined(__MINGW32__)
#define JSON_API __declspec(dllimport)
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
#endif // if defined(_MSC_VER)
#endif // ifdef JSON_IN_CPPTL
#if !defined(JSON_API)
#define JSON_API
#endif
#if defined(_MSC_VER) && _MSC_VER < 1800
#error \
"ERROR: Visual Studio 12 (2013) with _MSC_VER=1800 is the oldest supported compiler with sufficient C++11 capabilities"
#endif
#if defined(_MSC_VER) && _MSC_VER < 1900
// As recommended at
// https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
extern JSON_API int
msvc_pre1900_c99_snprintf(char* outBuf, size_t size, const char* format, ...);
#define jsoncpp_snprintf msvc_pre1900_c99_snprintf
#else
#define jsoncpp_snprintf std::snprintf
#endif
// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
// integer
// Storages, and 64 bits integer support is disabled.
// #define JSON_NO_INT64 1
#if defined(_MSC_VER) // MSVC
#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
#endif // defined(_MSC_VER)
// JSONCPP_OVERRIDE is maintained for backwards compatibility of external tools.
// C++11 should be used directly in JSONCPP.
#define JSONCPP_OVERRIDE override
#if __cplusplus >= 201103L
#define JSONCPP_NOEXCEPT noexcept
#define JSONCPP_OP_EXPLICIT explicit
#elif defined(_MSC_VER) && _MSC_VER < 1900
#define JSONCPP_NOEXCEPT throw()
#define JSONCPP_OP_EXPLICIT explicit
#elif defined(_MSC_VER) && _MSC_VER >= 1900
#define JSONCPP_NOEXCEPT noexcept
#define JSONCPP_OP_EXPLICIT explicit
#else
#define JSONCPP_NOEXCEPT throw()
#define JSONCPP_OP_EXPLICIT
#endif
#ifndef JSON_HAS_RVALUE_REFERENCES
#if defined(_MSC_VER)
#define JSON_HAS_RVALUE_REFERENCES 1
#endif // MSVC >= 2013
#ifdef __clang__
#if __has_feature(cxx_rvalue_references)
#define JSON_HAS_RVALUE_REFERENCES 1
#endif // has_feature
#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
#define JSON_HAS_RVALUE_REFERENCES 1
#endif // GXX_EXPERIMENTAL
#endif // __clang__ || __GNUC__
#endif // not defined JSON_HAS_RVALUE_REFERENCES
#ifndef JSON_HAS_RVALUE_REFERENCES
#define JSON_HAS_RVALUE_REFERENCES 0
#endif
#ifdef __clang__
#if __has_extension(attribute_deprecated_with_message)
#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
#endif
#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
#elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
#define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
#endif // GNUC version
#endif // __clang__ || __GNUC__
#if !defined(JSONCPP_DEPRECATED)
#define JSONCPP_DEPRECATED(message)
#endif // if !defined(JSONCPP_DEPRECATED)
#if __GNUC__ >= 6
#define JSON_USE_INT64_DOUBLE_CONVERSION 1
#endif
#if !defined(JSON_IS_AMALGAMATION)
#include "allocator.h"
#include "version.h"
#endif // if !defined(JSON_IS_AMALGAMATION)
namespace Json {
typedef int Int;
typedef unsigned int UInt;
#if defined(JSON_NO_INT64)
typedef int LargestInt;
typedef unsigned int LargestUInt;
#undef JSON_HAS_INT64
#else // if defined(JSON_NO_INT64)
// For Microsoft Visual use specific types as long long is not supported
#if defined(_MSC_VER) // Microsoft Visual Studio
typedef __int64 Int64;
typedef unsigned __int64 UInt64;
#else // if defined(_MSC_VER) // Other platforms, use long long
typedef int64_t Int64;
typedef uint64_t UInt64;
#endif // if defined(_MSC_VER)
typedef Int64 LargestInt;
typedef UInt64 LargestUInt;
#define JSON_HAS_INT64
#endif // if defined(JSON_NO_INT64)
template <typename T>
using Allocator = typename std::conditional<JSONCPP_USING_SECURE_MEMORY,
SecureAllocator<T>,
std::allocator<T>>::type;
using String = std::basic_string<char, std::char_traits<char>, Allocator<char>>;
using IStringStream = std::basic_istringstream<String::value_type,
String::traits_type,
String::allocator_type>;
using OStringStream = std::basic_ostringstream<String::value_type,
String::traits_type,
String::allocator_type>;
using IStream = std::istream;
using OStream = std::ostream;
} // namespace Json
// Legacy names (formerly macros).
using JSONCPP_STRING = Json::String;
using JSONCPP_ISTRINGSTREAM = Json::IStringStream;
using JSONCPP_OSTRINGSTREAM = Json::OStringStream;
using JSONCPP_ISTREAM = Json::IStream;
using JSONCPP_OSTREAM = Json::OStream;
#endif // JSON_CONFIG_H_INCLUDED
// //////////////////////////////////////////////////////////////////////
// End of content of file: include/json/config.h
// //////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////
// Beginning of content of file: include/json/forwards.h
// //////////////////////////////////////////////////////////////////////
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#ifndef JSON_FORWARDS_H_INCLUDED
#define JSON_FORWARDS_H_INCLUDED
#if !defined(JSON_IS_AMALGAMATION)
#include "config.h"
#endif // if !defined(JSON_IS_AMALGAMATION)
namespace Json {
// writer.h
class FastWriter;
class StyledWriter;
// reader.h
class Reader;
// features.h
class Features;
// value.h
typedef unsigned int ArrayIndex;
class StaticString;
class Path;
class PathArgument;
class Value;
class ValueIteratorBase;
class ValueIterator;
class ValueConstIterator;
} // namespace Json
#endif // JSON_FORWARDS_H_INCLUDED
// //////////////////////////////////////////////////////////////////////
// End of content of file: include/json/forwards.h
// //////////////////////////////////////////////////////////////////////
#endif //ifndef JSON_FORWARD_AMALGAMATED_H_INCLUDED

2366
dependencies/jsoncppdist/json/json.h vendored Normal file

File diff suppressed because it is too large Load Diff

5418
dependencies/jsoncppdist/jsoncpp.cpp vendored Normal file

File diff suppressed because it is too large Load Diff

1
jsonchecker/pass14.json Normal file
View File

@ -0,0 +1 @@
{"string with backandquote \\\"":1, "string with back\\":2}

View File

@ -0,0 +1 @@
{ "\"Name": [ 116,"\\\"", 234, "true", false ], "t": 1.0e+10}

View File

@ -0,0 +1,12 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 1.128 0.080 1.939 0.127
"RapidJSON " 4.996 0.201 0.441 0.017
"RapidJSON (insitu)" 3.910 0.122 0.563 0.017
"sajson (dynamic mem)" 3.149 0.063 0.699 0.014
"sajson" 2.116 0.058 1.038 0.028
"dropbox (json11) " 14.236 0.137 0.155 0.001
"fastjson " 9.305 0.429 0.237 0.010
"gason " 2.917 0.337 0.754 0.078
"ultrajson " 6.413 0.279 0.344 0.014
"jsmn " 37.170 0.232 0.059 0.000
"cJSON " 8.661 0.091 0.255 0.003

View File

@ -0,0 +1,12 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 2.452 0.050 0.900 0.018
"RapidJSON " 5.084 0.047 0.434 0.004
"RapidJSON (insitu)" 5.067 0.044 0.436 0.004
"sajson (dynamic mem)" 4.375 0.120 0.505 0.013
"sajson" 3.238 0.030 0.682 0.006
"dropbox (json11) " 35.101 0.229 0.063 0.000
"fastjson " 11.541 0.347 0.191 0.006
"gason " 3.489 0.667 0.633 0.102
"ultrajson " 5.596 0.027 0.394 0.002
"jsmn " 382.251 0.900 0.006 0.000
"cJSON " 32.573 0.793 0.068 0.002

View File

@ -0,0 +1,12 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 1.006 0.033 2.194 0.069
"RapidJSON " 3.265 0.039 0.676 0.008
"RapidJSON (insitu)" 3.100 0.026 0.712 0.006
"sajson (dynamic mem)" 3.344 0.065 0.660 0.013
"sajson" 2.068 0.052 1.067 0.026
"dropbox (json11) " 12.765 0.461 0.173 0.006
"fastjson " 6.849 0.988 0.322 0.041
"gason " 2.292 0.043 0.963 0.018
"ultrajson " 3.819 0.042 0.578 0.006
"jsmn " 12.229 0.078 0.181 0.001
"cJSON " 7.632 0.173 0.289 0.006

View File

@ -0,0 +1,12 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 1.016 0.089 2.130 0.174
"RapidJSON " 5.022 0.395 0.438 0.032
"RapidJSON (insitu)" 3.581 0.235 0.613 0.038
"sajson (dynamic mem)" 2.688 0.152 0.815 0.043
"sajson" 2.266 0.095 0.966 0.039
"dropbox (json11) " 16.039 0.246 0.137 0.002
"fastjson " 9.582 0.211 0.230 0.005
"gason " 2.957 0.229 0.741 0.052
"ultrajson " 6.861 0.232 0.321 0.011
"jsmn " 4.499 0.063 0.488 0.007
"cJSON " 8.840 0.163 0.249 0.004

View File

@ -0,0 +1,12 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 0.840 0.030 2.628 0.090
"RapidJSON " 4.617 0.118 0.478 0.012
"RapidJSON (insitu)" 2.835 0.024 0.779 0.006
"sajson (dynamic mem)" 2.356 0.025 0.937 0.010
"sajson" 1.943 0.017 1.136 0.010
"dropbox (json11) " 11.637 0.195 0.190 0.003
"fastjson " 8.641 1.068 0.255 0.028
"gason " 2.588 0.034 0.853 0.011
"ultrajson " 5.439 0.080 0.406 0.006
"jsmn " 14.814 0.094 0.149 0.001
"cJSON " 5.400 0.083 0.409 0.006

View File

@ -0,0 +1,12 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 1.236 0.083 1.778 0.112
"RapidJSON " 4.238 0.129 0.520 0.015
"RapidJSON (insitu)" 3.932 0.109 0.561 0.015
"sajson (dynamic mem)" 3.807 0.064 0.579 0.010
"sajson" 2.378 0.042 0.926 0.016
"dropbox (json11) " 17.152 0.202 0.129 0.001
"fastjson " 7.785 0.768 0.283 0.025
"gason " 2.822 0.375 0.781 0.092
"ultrajson " 6.106 0.122 0.361 0.007
"jsmn " 9.853 0.081 0.224 0.002
"cJSON " 9.924 0.088 0.222 0.002

View File

@ -0,0 +1,12 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 2.746 0.066 0.804 0.019
"RapidJSON " 6.105 0.050 0.362 0.003
"RapidJSON (insitu)" 5.867 0.039 0.376 0.003
"sajson (dynamic mem)" 5.258 0.333 0.420 0.025
"sajson" 3.555 0.063 0.621 0.011
"dropbox (json11) " 31.563 4.146 0.070 0.008
"fastjson " 12.260 0.409 0.180 0.006
"gason " 3.604 0.943 0.613 0.127
"ultrajson " 7.062 0.066 0.313 0.003
"jsmn " 15.600 0.488 0.142 0.004
"cJSON " 30.865 2.423 0.072 0.005

View File

@ -0,0 +1,12 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 2.742 0.109 0.805 0.031
"RapidJSON " 5.868 0.126 0.376 0.008
"RapidJSON (insitu)" 5.901 0.065 0.374 0.004
"sajson (dynamic mem)" 5.475 0.171 0.403 0.012
"sajson" 3.860 0.087 0.572 0.013
"dropbox (json11) " 28.076 0.352 0.079 0.001
"fastjson " 13.015 0.217 0.170 0.003
"gason " 3.717 0.940 0.594 0.120
"ultrajson " 6.710 0.092 0.329 0.004
"jsmn " 47.987 0.317 0.046 0.000
"cJSON " 35.302 0.433 0.063 0.001

View File

@ -0,0 +1,12 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 1.816 0.036 1.215 0.023
"RapidJSON " 3.584 0.070 0.616 0.012
"RapidJSON (insitu)" 3.589 0.032 0.615 0.005
"sajson (dynamic mem)" 4.337 0.248 0.509 0.027
"sajson" 2.588 0.036 0.853 0.012
"dropbox (json11) " 16.129 0.201 0.137 0.002
"fastjson " 7.866 0.249 0.281 0.009
"gason " 2.618 0.480 0.843 0.131
"ultrajson " 3.762 0.041 0.587 0.006
"jsmn " 23.841 0.197 0.093 0.001
"cJSON " 17.739 0.260 0.124 0.002

View File

@ -0,0 +1,12 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 2.292 0.125 0.960 0.050
"RapidJSON " 4.812 0.168 0.458 0.015
"RapidJSON (insitu)" 4.846 0.109 0.455 0.010
"sajson (dynamic mem)" 4.566 0.079 0.482 0.008
"sajson" 3.067 0.063 0.718 0.014
"dropbox (json11) " 25.393 0.190 0.087 0.001
"fastjson " 11.008 0.306 0.200 0.005
"gason " 3.189 0.701 0.690 0.124
"ultrajson " 5.492 0.108 0.401 0.008
"jsmn " 4.822 0.147 0.457 0.013
"cJSON " 29.293 0.500 0.075 0.001

View File

@ -0,0 +1,12 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 1.768 0.068 1.247 0.046
"RapidJSON " 6.532 0.105 0.338 0.005
"RapidJSON (insitu)" 5.397 0.032 0.409 0.002
"sajson (dynamic mem)" 5.900 0.073 0.374 0.005
"sajson" 3.095 0.062 0.713 0.014
"dropbox (json11) " 26.067 1.026 0.085 0.003
"fastjson " 10.810 0.261 0.204 0.005
"gason " 3.417 0.650 0.646 0.103
"ultrajson " 8.801 0.109 0.251 0.003
"jsmn " 79.479 0.333 0.028 0.000
"cJSON " 13.740 0.289 0.161 0.003

View File

@ -0,0 +1,12 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 1.132 0.066 1.948 0.108
"RapidJSON " 5.186 0.085 0.426 0.007
"RapidJSON (insitu)" 3.759 0.049 0.587 0.008
"sajson (dynamic mem)" 3.639 0.053 0.606 0.009
"sajson" 2.428 0.056 0.909 0.020
"dropbox (json11) " 17.214 0.473 0.128 0.003
"fastjson " 10.042 0.646 0.220 0.013
"gason " 3.227 0.071 0.684 0.015
"ultrajson " 6.217 0.066 0.355 0.004
"jsmn " 9.050 0.091 0.244 0.002
"cJSON " 7.565 0.088 0.292 0.003

View File

@ -0,0 +1,12 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 2.290 0.070 0.963 0.029
"RapidJSON " 6.236 0.110 0.354 0.006
"RapidJSON (insitu)" 4.400 0.066 0.501 0.007
"sajson (dynamic mem)" 4.176 0.046 0.528 0.006
"sajson" 2.886 0.055 0.764 0.014
"dropbox (json11) " 22.869 0.275 0.097 0.001
"fastjson " 10.673 0.288 0.207 0.005
"gason " 3.841 0.093 0.574 0.014
"ultrajson " 7.277 0.121 0.303 0.005
"jsmn " 9.810 0.100 0.225 0.002
"cJSON " 9.588 0.086 0.230 0.002

View File

@ -0,0 +1,12 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 1.430 0.071 1.542 0.073
"RapidJSON " 6.277 0.147 0.352 0.008
"RapidJSON (insitu)" 4.859 0.036 0.454 0.003
"sajson (dynamic mem)" 5.213 0.060 0.423 0.005
"sajson" 2.881 0.063 0.766 0.016
"dropbox (json11) " 22.860 0.369 0.097 0.002
"fastjson " 12.205 0.821 0.181 0.011
"gason " 3.683 0.156 0.599 0.024
"ultrajson " 8.590 0.140 0.257 0.004
"jsmn " 38.342 0.295 0.058 0.000
"cJSON " 10.162 0.127 0.217 0.003

View File

@ -1,4 +1,4 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 1.126 0.095 1.942 0.151
"RapidJSON" 3.906 0.210 0.563 0.028
"sajson" 2.063 0.066 1.065 0.033
"simdjson " 1.126 0.080 1.943 0.128
"RapidJSON (insitu)" 3.873 0.202 0.568 0.028
"sajson" 1.994 0.045 1.102 0.024

View File

@ -1,4 +1,4 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 2.469 0.048 0.894 0.017
"RapidJSON" 5.154 0.042 0.428 0.003
"sajson" 3.235 0.053 0.682 0.011
"simdjson " 2.448 0.049 0.902 0.018
"RapidJSON (insitu)" 5.074 0.038 0.435 0.003
"sajson" 3.264 0.198 0.676 0.039

View File

@ -1,4 +1,4 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 1.006 0.038 2.193 0.081
"RapidJSON" 3.247 0.033 0.680 0.007
"sajson" 2.032 0.066 1.086 0.034
"simdjson " 1.005 0.030 2.195 0.065
"RapidJSON (insitu)" 3.055 0.087 0.723 0.020
"sajson" 1.999 0.036 1.104 0.019

View File

@ -1,4 +1,4 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 1.025 0.099 2.113 0.185
"RapidJSON" 3.650 0.288 0.602 0.044
"sajson" 2.187 0.288 1.000 0.115
"simdjson " 1.031 0.097 2.100 0.177
"RapidJSON (insitu)" 3.551 0.340 0.618 0.054
"sajson" 2.218 0.175 0.987 0.072

View File

@ -1,4 +1,4 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 0.845 0.035 2.610 0.103
"RapidJSON" 2.860 0.017 0.772 0.005
"sajson" 1.914 0.017 1.153 0.010
"simdjson " 0.842 0.030 2.621 0.090
"RapidJSON (insitu)" 2.840 0.027 0.777 0.007
"sajson" 1.908 0.016 1.157 0.010

View File

@ -1,4 +1,4 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 1.240 0.099 1.772 0.131
"RapidJSON" 4.010 0.118 0.550 0.016
"sajson" 2.326 0.068 0.947 0.027
"simdjson " 1.236 0.092 1.777 0.122
"RapidJSON (insitu)" 3.853 0.133 0.572 0.019
"sajson" 2.345 0.054 0.939 0.021

View File

@ -1,4 +1,4 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 2.750 0.058 0.803 0.017
"RapidJSON" 6.121 0.051 0.361 0.003
"sajson" 3.774 0.057 0.585 0.009
"simdjson " 2.788 0.069 0.792 0.019
"RapidJSON (insitu)" 5.928 0.062 0.372 0.004
"sajson" 3.602 0.059 0.613 0.010

View File

@ -1,4 +1,4 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 2.798 0.102 0.789 0.028
"RapidJSON" 6.003 0.120 0.368 0.007
"sajson" 3.713 0.129 0.594 0.020
"simdjson " 2.777 0.122 0.795 0.033
"RapidJSON (insitu)" 5.898 0.116 0.374 0.007
"sajson" 3.774 0.101 0.585 0.015

View File

@ -1,4 +1,4 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 1.817 0.043 1.215 0.028
"RapidJSON" 3.593 0.049 0.614 0.008
"sajson" 2.582 0.094 0.855 0.030
"simdjson " 1.817 0.046 1.214 0.030
"RapidJSON (insitu)" 3.576 0.057 0.617 0.010
"sajson" 2.652 0.062 0.832 0.019

View File

@ -1,4 +1,4 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 2.305 0.158 0.954 0.061
"RapidJSON" 4.864 0.160 0.453 0.014
"sajson" 3.161 0.055 0.696 0.012
"simdjson " 2.453 0.157 0.897 0.054
"RapidJSON (insitu)" 4.856 0.185 0.454 0.017
"sajson" 3.084 0.074 0.714 0.017

View File

@ -14,6 +14,8 @@ def getdata(filename):
ourdir=os.path.dirname(os.path.realpath(__file__))
answer = []
for file in os.listdir(ourdir):
if file.startswith("all"):
continue
if file.endswith(".table"):
fullpath = os.path.join(ourdir, file)
answer.append([file[:-11]]+getdata(fullpath))
@ -21,3 +23,6 @@ print("#simdjson RapidJSON sajson")
answer.sort()
for l in answer:
print("\t".join(map(str,l)))

View File

@ -1,4 +1,4 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 1.777 0.082 1.241 0.055
"RapidJSON" 5.434 0.072 0.406 0.005
"sajson" 2.973 0.095 0.742 0.023
"simdjson " 1.782 0.084 1.237 0.055
"RapidJSON (insitu)" 5.366 0.090 0.411 0.007
"sajson" 2.978 0.060 0.741 0.015

View File

@ -1,4 +1,4 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 1.145 0.050 1.925 0.081
"RapidJSON" 3.852 0.054 0.573 0.008
"sajson" 2.406 0.045 0.917 0.017
"simdjson " 1.146 0.065 1.924 0.104
"RapidJSON (insitu)" 3.771 0.061 0.585 0.009
"sajson" 2.392 0.057 0.922 0.021

View File

@ -1,4 +1,4 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 2.287 0.089 0.964 0.037
"RapidJSON" 4.495 0.050 0.491 0.005
"sajson" 2.870 0.062 0.769 0.016
"simdjson " 2.294 0.069 0.962 0.028
"RapidJSON (insitu)" 4.394 0.064 0.502 0.007
"sajson" 2.827 0.056 0.780 0.015

View File

@ -1,4 +1,4 @@
name cycles_per_byte cycles_per_byte_err gb_per_s gb_per_s_err
"simdjson " 1.438 0.078 1.533 0.081
"RapidJSON" 4.952 0.077 0.446 0.007
"sajson" 2.798 0.102 0.788 0.028
"simdjson " 1.437 0.078 1.534 0.079
"RapidJSON (insitu)" 4.855 0.104 0.455 0.010
"sajson" 2.772 0.059 0.796 0.017

View File

@ -0,0 +1,23 @@
import os
import csv
try: import pandas as pd
except ImportError:
import pip
pip.main(['install', '--user', 'pandas'])
import pandas as pd
def getdata(filename):
df = pd.read_csv(filename, delim_whitespace=True)
return (df["gb_per_s"].tolist())
ourdir=os.path.dirname(os.path.realpath(__file__))
answer = []
for file in os.listdir(ourdir):
if file.startswith("all") and file.endswith(".table"):
fullpath = os.path.join(ourdir, file)
answer.append([file[3:-11]]+getdata(fullpath))
print(" \t&\t simdjson \t&\t RapidJSON \t&\t RapidJSONinsitu \t&\t sajsondyn \t&\t sajson \t&\t dropbox-json11 \t&\t fastjson \t&\t gason \t&\t ultrajson \t&\t jsmn\t&\t cJSON \\\\")
answer.sort()
for l in answer:
print("\t&\t".join(map(lambda x : (('{:.2f}'.format(x) if x < 1 else '{:.1f}'.format(x) ) if (type(x) is float) else x),l))+"\\\\")

View File

@ -1,6 +1,11 @@
import os
import csv
import pandas as pd
try: import pandas as pd
except ImportError:
import pip
pip.main(['install', '--user', 'pandas'])
import pandas as pd
def getdata(filename):
df = pd.read_csv(filename, delim_whitespace=True)
@ -9,6 +14,8 @@ def getdata(filename):
ourdir=os.path.dirname(os.path.realpath(__file__))
answer = []
for file in os.listdir(ourdir):
if file.startswith("all"):
continue
if file.endswith(".table"):
fullpath = os.path.join(ourdir, file)
answer.append([file[:-11]]+getdata(fullpath))
@ -16,3 +23,6 @@ print("#simdjson RapidJSON sajson")
answer.sort()
for l in answer:
print("\t".join(map(str,l)))

View File

@ -40,12 +40,6 @@ bool json_parse(const uint8_t *buf, size_t len, ParsedJson &pj, bool reallocifne
}
}
bool isok = find_structural_bits(buf, len, pj);
/*if (isok) {
isok = flatten_indexes(len, pj);
} else {
if(reallocated) free((void*)buf);
return false;
}*/
if (isok) {
isok = unified_machine(buf, len, pj);
} else {

View File

@ -23,6 +23,8 @@ extern "C"
#include "jsmn.h"
#include "jsmn.c"
}
#include "json/json.h"
#include "jsoncpp.cpp"
using namespace rapidjson;
using namespace std;
@ -127,6 +129,12 @@ int main(int argc, char *argv[]) {
cJSON_Delete(tree);
}
Json::CharReaderBuilder b;
Json::CharReader * jsoncppreader = b.newCharReader();
Json::Value root;
Json::String errs;
bool isjsoncppok = jsoncppreader->parse(buffer,buffer+p.size(),&root,&errs);
delete jsoncppreader;
printf("our parser : %s \n", ours_correct ? "correct":"invalid");
@ -137,8 +145,9 @@ int main(int argc, char *argv[]) {
printf("fastjson : %s \n", fastjson_correct ? "correct":"invalid");
printf("gason : %s \n", gason_correct ? "correct":"invalid");
printf("ultrajson : %s \n", ultrajson_correct ? "correct":"invalid");
printf("jsmn_correct : %s \n", jsmn_correct ? "correct":"invalid");
printf("cjson_correct : %s \n", cjson_correct ? "correct":"invalid");
printf("jsmn : %s \n", jsmn_correct ? "correct":"invalid");
printf("cjson : %s \n", cjson_correct ? "correct":"invalid");
printf("jsoncpp : %s \n", isjsoncppok ? "correct":"invalid");
aligned_free((void*)p.data());
free(buffer);