31#define SIMD_SUFFIX(name) name##_SSE2
32#elif defined(RAPIDJSON_SSE42)
33#define SIMD_SUFFIX(name) name##_SSE42
34#elif defined(RAPIDJSON_NEON)
35#define SIMD_SUFFIX(name) name##_NEON
37#define SIMD_SUFFIX(name) name
50 temp_ = (
char *)malloc(length_ + 1);
55 for (
size_t i = 0; i < 7; i++)
75 for (
size_t i = 0; i < kTrialCount; i++) {
76 memcpy(temp_, json_, length_ + 1);
85 for (
size_t i = 0; i < kTrialCount; i++) {
86 memcpy(temp_, json_, length_ + 1);
95 for (
size_t i = 0; i < kTrialCount; i++) {
103#define TEST_TYPED(index, Name)\
104TEST_F(RapidJson, SIMD_SUFFIX(ReaderParse_DummyHandler_##Name)) {\
105 for (size_t i = 0; i < kTrialCount * 10; i++) {\
106 StringStream s(types_[index]);\
107 BaseReaderHandler<> h;\
109 EXPECT_TRUE(reader.Parse(s, h));\
112TEST_F(RapidJson, SIMD_SUFFIX(ReaderParseInsitu_DummyHandler_##Name)) {\
113 for (size_t i = 0; i < kTrialCount * 10; i++) {\
114 memcpy(temp_, types_[index], typesLength_[index] + 1);\
115 InsituStringStream s(temp_);\
116 BaseReaderHandler<> h;\
118 EXPECT_TRUE(reader.Parse<kParseInsituFlag>(s, h));\
133 for (
size_t i = 0; i < kTrialCount; i++) {
142 for (
size_t i = 0; i < kTrialCount; i++) {
151 for (
size_t i = 0; i < kTrialCount; i++) {
152 memcpy(temp_, json_, length_ + 1);
161 for (
size_t i = 0; i < kTrialCount; i++) {
175 for (
size_t i = 0; i < kTrialCount; i++) {
176 memcpy(temp_, json_, length_ + 1);
190 for (
size_t i = 0; i < kTrialCount; i++) {
199 for (
size_t i = 0; i < kTrialCount; i++) {
200 memcpy(temp_, json_, length_ + 1);
208 for (
size_t i = 0; i < kTrialCount; i++) {
209 memcpy(temp_, json_, length_ + 1);
217 for (
size_t i = 0; i < kTrialCount; i++) {
225 for (
size_t i = 0; i < kTrialCount; i++) {
227 doc.
Parse(json_, length_);
232#if RAPIDJSON_HAS_STDSTRING
234 const std::string
s(json_, length_);
235 for (
size_t i = 0; i < kTrialCount; i++) {
244 for (
size_t i = 0; i < kTrialCount; i++) {
252 for (
size_t i = 0; i < kTrialCount; i++) {
253 memcpy(temp_, json_, length_ + 1);
261 for (
size_t i = 0; i < kTrialCount; i++) {
271 for (
size_t i = 0; i < kTrialCount; i++) {
283 switch(
value.GetType()) {
285 for (
typename T::ConstMemberIterator itr =
value.MemberBegin(); itr !=
value.MemberEnd(); ++itr) {
292 for (
typename T::ConstValueIterator itr =
value.Begin(); itr !=
value.End(); ++itr)
304 for (
size_t i = 0; i < kTrialCount; i++) {
314RAPIDJSON_DIAG_OFF(effc++)
331 for (
size_t i = 0; i < kTrialCount; i++) {
333 doc_.Accept(counter);
348 for (
size_t i = 0; i < kTrialCount; i++) {
358 for (
size_t i = 0; i < kTrialCount; i++) {
362 const char* str =
s.GetString();
369#define TEST_TYPED(index, Name)\
370TEST_F(RapidJson, SIMD_SUFFIX(Writer_StringBuffer_##Name)) {\
371 for (size_t i = 0; i < kTrialCount * 10; i++) {\
372 StringBuffer s(0, 1024 * 1024);\
373 Writer<StringBuffer> writer(s);\
374 typesDoc_[index].Accept(writer);\
375 const char* str = s.GetString();\
391 for (
size_t i = 0; i < kTrialCount; i++) {
396 const char* str =
s.GetString();
405 for (
size_t i = 0; i < kTrialCount * kTrialCount; i++)
411 for (
size_t i = 0; i < kTrialCount; i++) {
412 rapidjson::StringStream
s(whitespace_);
413 while (
s.Peek() ==
' ' ||
s.Peek() ==
'\n' ||
s.Peek() ==
'\r' ||
s.Peek() ==
'\t')
420 for (
size_t i = 0; i < kTrialCount; i++) {
421 rapidjson::StringStream
s(whitespace_);
422 rapidjson::SkipWhitespace(
s);
428 for (
size_t i = 0; i < kTrialCount; i++) {
429 const char*
s = whitespace_ + std::strspn(whitespace_,
" \t\r\n");
437 for (
size_t i = 0; i < kTrialCount; i++) {
440 while (is.Peek() !=
'\0')
447 for (
size_t i = 0; i < kTrialCount; i++) {
448 FILE *fp = fopen(filename_,
"rb");
451 while (
s.Take() !=
'\0')
458 for (
size_t i = 0; i < kTrialCount; i++) {
459 FILE *fp = fopen(filename_,
"rb");
470 for (
size_t i = 0; i < kTrialCount; i++) {
471 std::ifstream is(filename_, std::ios::in | std::ios::binary);
474 while (isw.
Take() !=
'\0')
481 for (
size_t i = 0; i < kTrialCount; i++) {
482 std::ifstream is(filename_, std::ios::in | std::ios::binary);
484 while (isw.
Take() !=
'\0')
491 for (
size_t i = 0; i < kTrialCount; i++) {
494 is.rdbuf()->pubsetbuf(buffer,
sizeof(buffer));
495 is.open(filename_, std::ios::in | std::ios::binary);
497 while (isw.
Take() !=
'\0')
504 for (
size_t i = 0; i < kTrialCount; i++) {
505 std::ifstream is(filename_, std::ios::in | std::ios::binary);
510 reader.
Parse(isw, h);
516 for (
size_t i = 0; i < kTrialCount; i++) {
517 std::ifstream is(filename_, std::ios::in | std::ios::binary);
521 reader.
Parse(isw, h);
527 for (
size_t i = 0; i < kTrialCount; i++) {
530 is.rdbuf()->pubsetbuf(buffer,
sizeof(buffer));
531 is.open(filename_, std::ios::in | std::ios::binary);
535 reader.
Parse(isw, h);
542 for (
int i = 0; i < 32 * 1024 * 1024; i++)
C-runtime library allocator.
File byte stream for input using fread().
GenericDocument & ParseInsitu(Ch *str)
Parse JSON text from a mutable string.
bool HasParseError() const
Whether a parse error has occurred in the last parsing.
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream (with Encoding conversion)
GenericDocument & Parse(const typename SourceEncoding::Ch *str)
Parse JSON text from a read-only string (with Encoding conversion)
ParseResult Parse(InputStream &is, Handler &handler)
Parse JSON text.
bool IterativeParseNext(InputStream &is, Handler &handler)
Parse one token from JSON text.
void IterativeParseInit()
Initialize JSON text token-by-token parsing.
RAPIDJSON_FORCEINLINE bool IterativeParseComplete() const
Check if token-by-token parsing JSON text is complete.
bool HasParseError() const
Whether a parse error has occurred in the last parsing.
Writer with indentation and spacing.
PrettyWriter & SetIndent(Ch indentChar, unsigned indentCharCount)
Set custom indentation.
#define TEST_F(test_fixture, test_name)
#define ASSERT_EQ(val1, val2)
#define EXPECT_EQ(val1, val2)
#define EXPECT_GT(val1, val2)
#define EXPECT_TRUE(condition)
#define ASSERT_TRUE(condition)
#define EXPECT_FALSE(condition)
double Pow10(int n)
Computes integer powers of 10 in double (10.0^n).
#define T(meth, val, expected)
common definitions and configuration
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
#define SIMD_SUFFIX(name)
#define TEST_TYPED(index, Name)
size_t Traverse(const T &value)
void SkipWhitespace(InputStream &is)
Skip the JSON white spaces in a stream.
@ kParseFullPrecisionFlag
Parse number in full precision (but slower).
@ kParseInsituFlag
In-situ(destructive) parsing.
@ kParseDefaultFlags
Default parse flags. Can be customized by defining RAPIDJSON_PARSE_DEFAULT_FLAGS.
@ kParseValidateEncodingFlag
Validate encoding of JSON strings.
@ kParseIterativeFlag
Iterative(constant complexity in terms of function call stack size) parsing.
Dynamically select encoding according to stream's runtime-specified UTF encoding type.
Default implementation of Handler.
Represents an in-memory input byte stream.
bool EndArray(SizeType elementCount)
bool EndObject(SizeType memberCount)
memcpy((char *) pInfo->slotDescription, s, l)