Bump rapidjson version (#6906)

This commit is contained in:
Siarhei Fedartsou
2024-05-27 08:31:59 +02:00
committed by GitHub
parent 667fd198ac
commit 163a2cfe3c
151 changed files with 14287 additions and 2363 deletions
+2
View File
@@ -19,6 +19,8 @@ if(CCACHE_FOUND)
endif()
endif(CCACHE_FOUND)
set_property(DIRECTORY PROPERTY COMPILE_OPTIONS ${EXTRA_CXX_FLAGS})
IF(NOT (CMAKE_BUILD_TYPE STREQUAL "Debug"))
add_test(NAME perftest
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/perftest
+3 -3
View File
@@ -1,6 +1,6 @@
// Tencent is pleased to support the open source community by making RapidJSON available.
//
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
//
// Licensed under the MIT License (the "License"); you may not use this file except
// in compliance with the License. You may obtain a copy of the License at
@@ -432,7 +432,7 @@ bool Writer1<rapidjson::StringBuffer>::WriteUint(unsigned u) {
return true;
}
// Using digits LUT to reduce divsion/modulo
// Using digits LUT to reduce division/modulo
template<typename OutputStream>
class Writer2 {
public:
@@ -616,7 +616,7 @@ inline bool Writer3<rapidjson::InsituStringStream>::WriteUint64(uint64_t u) {
return true;
}
// Using digits LUT to reduce divsion/modulo, two passes
// Using digits LUT to reduce division/modulo, two passes
template<typename OutputStream>
class Writer4 {
public:
+1 -1
View File
@@ -1,6 +1,6 @@
// Tencent is pleased to support the open source community by making RapidJSON available.
//
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
//
// Licensed under the MIT License (the "License"); you may not use this file except
// in compliance with the License. You may obtain a copy of the License at
+9 -5
View File
@@ -1,6 +1,6 @@
// Tencent is pleased to support the open source community by making RapidJSON available.
//
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
//
// Licensed under the MIT License (the "License"); you may not use this file except
// in compliance with the License. You may obtain a copy of the License at
@@ -24,10 +24,13 @@
// __SSE2__ and __SSE4_2__ are recognized by gcc, clang, and the Intel compiler.
// We use -march=native with gmake to enable -msse2 and -msse4.2, if supported.
// Likewise, __ARM_NEON is used to detect Neon.
#if defined(__SSE4_2__)
# define RAPIDJSON_SSE42
#elif defined(__SSE2__)
# define RAPIDJSON_SSE2
#elif defined(__ARM_NEON)
# define RAPIDJSON_NEON
#endif
#define RAPIDJSON_HAS_STDSTRING 1
@@ -127,7 +130,8 @@ public:
"integers.json",
"mixed.json",
"nulls.json",
"paragraphs.json"
"paragraphs.json",
"alotofkeys.json"
};
for (size_t j = 0; j < sizeof(typesfilenames) / sizeof(typesfilenames[0]); j++) {
@@ -155,7 +159,7 @@ public:
free(whitespace_);
json_ = 0;
whitespace_ = 0;
for (size_t i = 0; i < 7; i++) {
for (size_t i = 0; i < 8; i++) {
free(types_[i]);
types_[i] = 0;
}
@@ -171,8 +175,8 @@ protected:
size_t length_;
char *whitespace_;
size_t whitespace_length_;
char *types_[7];
size_t typesLength_[7];
char *types_[8];
size_t typesLength_[8];
static const size_t kTrialCount = 1000;
};
+2 -2
View File
@@ -1,6 +1,6 @@
// Tencent is pleased to support the open source community by making RapidJSON available.
//
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
//
// Licensed under the MIT License (the "License"); you may not use this file except
// in compliance with the License. You may obtain a copy of the License at
@@ -76,7 +76,7 @@ TEST_F(Platform, strlen) {
TEST_F(Platform, memcmp) {
for (int i = 0; i < kTrialCount; i++) {
EXPECT_EQ(0, memcmp(temp_, json_, length_));
EXPECT_EQ(0u, memcmp(temp_, json_, length_));
}
}
+126 -3
View File
@@ -1,6 +1,6 @@
// Tencent is pleased to support the open source community by making RapidJSON available.
//
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
//
// Licensed under the MIT License (the "License"); you may not use this file except
// in compliance with the License. You may obtain a copy of the License at
@@ -21,13 +21,19 @@
#include "rapidjson/prettywriter.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/filereadstream.h"
#include "rapidjson/istreamwrapper.h"
#include "rapidjson/encodedstream.h"
#include "rapidjson/memorystream.h"
#include <fstream>
#include <vector>
#ifdef RAPIDJSON_SSE2
#define SIMD_SUFFIX(name) name##_SSE2
#elif defined(RAPIDJSON_SSE42)
#define SIMD_SUFFIX(name) name##_SSE42
#elif defined(RAPIDJSON_NEON)
#define SIMD_SUFFIX(name) name##_NEON
#else
#define SIMD_SUFFIX(name) name
#endif
@@ -47,7 +53,7 @@ public:
// Parse as a document
EXPECT_FALSE(doc_.Parse(json_).HasParseError());
for (size_t i = 0; i < 7; i++)
for (size_t i = 0; i < 8; i++)
EXPECT_FALSE(typesDoc_[i].Parse(types_[i]).HasParseError());
}
@@ -63,7 +69,7 @@ private:
protected:
char *temp_;
Document doc_;
Document typesDoc_[7];
Document typesDoc_[8];
};
TEST_F(RapidJson, SIMD_SUFFIX(ReaderParseInsitu_DummyHandler)) {
@@ -152,6 +158,35 @@ TEST_F(RapidJson, SIMD_SUFFIX(ReaderParseIterativeInsitu_DummyHandler)) {
}
}
TEST_F(RapidJson, SIMD_SUFFIX(ReaderParseIterativePull_DummyHandler)) {
for (size_t i = 0; i < kTrialCount; i++) {
StringStream s(json_);
BaseReaderHandler<> h;
Reader reader;
reader.IterativeParseInit();
while (!reader.IterativeParseComplete()) {
if (!reader.IterativeParseNext<kParseDefaultFlags>(s, h))
break;
}
EXPECT_FALSE(reader.HasParseError());
}
}
TEST_F(RapidJson, SIMD_SUFFIX(ReaderParseIterativePullInsitu_DummyHandler)) {
for (size_t i = 0; i < kTrialCount; i++) {
memcpy(temp_, json_, length_ + 1);
InsituStringStream s(temp_);
BaseReaderHandler<> h;
Reader reader;
reader.IterativeParseInit();
while (!reader.IterativeParseComplete()) {
if (!reader.IterativeParseNext<kParseDefaultFlags|kParseInsituFlag>(s, h))
break;
}
EXPECT_FALSE(reader.HasParseError());
}
}
TEST_F(RapidJson, SIMD_SUFFIX(ReaderParse_DummyHandler_ValidateEncoding)) {
for (size_t i = 0; i < kTrialCount; i++) {
StringStream s(json_);
@@ -301,6 +336,23 @@ TEST_F(RapidJson, DocumentAccept) {
}
}
TEST_F(RapidJson, DocumentFind) {
typedef Document::ValueType ValueType;
typedef ValueType::ConstMemberIterator ConstMemberIterator;
const Document &doc = typesDoc_[7]; // alotofkeys.json
if (doc.IsObject()) {
std::vector<const ValueType*> keys;
for (ConstMemberIterator it = doc.MemberBegin(); it != doc.MemberEnd(); ++it) {
keys.push_back(&it->name);
}
for (size_t i = 0; i < kTrialCount; i++) {
for (size_t j = 0; j < keys.size(); j++) {
EXPECT_TRUE(doc.FindMember(*keys[j]) != doc.MemberEnd());
}
}
}
}
struct NullStream {
typedef char Ch;
@@ -432,6 +484,77 @@ TEST_F(RapidJson, SIMD_SUFFIX(ReaderParse_DummyHandler_FileReadStream)) {
}
}
TEST_F(RapidJson, IStreamWrapper) {
for (size_t i = 0; i < kTrialCount; i++) {
std::ifstream is(filename_, std::ios::in | std::ios::binary);
char buffer[65536];
IStreamWrapper isw(is, buffer, sizeof(buffer));
while (isw.Take() != '\0')
;
is.close();
}
}
TEST_F(RapidJson, IStreamWrapper_Unbuffered) {
for (size_t i = 0; i < kTrialCount; i++) {
std::ifstream is(filename_, std::ios::in | std::ios::binary);
IStreamWrapper isw(is);
while (isw.Take() != '\0')
;
is.close();
}
}
TEST_F(RapidJson, IStreamWrapper_Setbuffered) {
for (size_t i = 0; i < kTrialCount; i++) {
std::ifstream is;
char buffer[65536];
is.rdbuf()->pubsetbuf(buffer, sizeof(buffer));
is.open(filename_, std::ios::in | std::ios::binary);
IStreamWrapper isw(is);
while (isw.Take() != '\0')
;
is.close();
}
}
TEST_F(RapidJson, SIMD_SUFFIX(ReaderParse_DummyHandler_IStreamWrapper)) {
for (size_t i = 0; i < kTrialCount; i++) {
std::ifstream is(filename_, std::ios::in | std::ios::binary);
char buffer[65536];
IStreamWrapper isw(is, buffer, sizeof(buffer));
BaseReaderHandler<> h;
Reader reader;
reader.Parse(isw, h);
is.close();
}
}
TEST_F(RapidJson, SIMD_SUFFIX(ReaderParse_DummyHandler_IStreamWrapper_Unbuffered)) {
for (size_t i = 0; i < kTrialCount; i++) {
std::ifstream is(filename_, std::ios::in | std::ios::binary);
IStreamWrapper isw(is);
BaseReaderHandler<> h;
Reader reader;
reader.Parse(isw, h);
is.close();
}
}
TEST_F(RapidJson, SIMD_SUFFIX(ReaderParse_DummyHandler_IStreamWrapper_Setbuffered)) {
for (size_t i = 0; i < kTrialCount; i++) {
std::ifstream is;
char buffer[65536];
is.rdbuf()->pubsetbuf(buffer, sizeof(buffer));
is.open(filename_, std::ios::in | std::ios::binary);
IStreamWrapper isw(is);
BaseReaderHandler<> h;
Reader reader;
reader.Parse(isw, h);
is.close();
}
}
TEST_F(RapidJson, StringBuffer) {
StringBuffer sb;
for (int i = 0; i < 32 * 1024 * 1024; i++)
+7
View File
@@ -11,6 +11,11 @@
using namespace rapidjson;
RAPIDJSON_DIAG_PUSH
#if defined(__GNUC__) && __GNUC__ >= 7
RAPIDJSON_DIAG_OFF(format-overflow)
#endif
template <typename Allocator>
static char* ReadFile(const char* filename, Allocator& allocator) {
const char *paths[] = {
@@ -42,6 +47,8 @@ static char* ReadFile(const char* filename, Allocator& allocator) {
return json;
}
RAPIDJSON_DIAG_POP
class Schema : public PerfTest {
public:
Schema() {}