18 #define TEST_RAPIDJSON 1 19 #define TEST_PLATFORM 0 22 #define TEST_VERSION_CODE(x,y,z) \ 23 (((x)*100000) + ((y)*100) + (z)) 27 #if defined(__SSE4_2__) 28 # define RAPIDJSON_SSE42 29 #elif defined(__SSE2__) 30 # define RAPIDJSON_SSE2 33 #define RAPIDJSON_HAS_STDSTRING 1 41 #ifndef __STDC_CONSTANT_MACROS 42 # define __STDC_CONSTANT_MACROS 1 // required by C++ standard 45 #if defined(__clang__) || defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) 46 #if defined(__clang__) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) 47 #pragma GCC diagnostic push 49 #pragma GCC diagnostic ignored "-Weffc++" 52 #include "gtest/gtest.h" 54 #if defined(__clang__) || defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) 55 #pragma GCC diagnostic pop 59 #define _CRTDBG_MAP_ALLOC 61 #pragma warning(disable : 4996) // 'function': was declared deprecated 65 class PerfTest :
public ::testing::Test {
67 PerfTest() : filename_(), json_(), length_(), whitespace_(), whitespace_length_() {}
69 virtual void SetUp() {
71 const char *
paths[] = {
73 "bin/data/sample.json",
74 "../bin/data/sample.json",
75 "../../bin/data/sample.json",
76 "../../../bin/data/sample.json" 80 for (
size_t i = 0; i <
sizeof(
paths) /
sizeof(
paths[0]); i++) {
88 length_ = (size_t)
ftell(fp);
90 json_ = (
char*)
malloc(length_ + 1);
91 ASSERT_EQ(length_,
fread(json_, 1, length_, fp));
92 json_[length_] =
'\0';
98 whitespace_length_ = 1024 * 1024;
99 whitespace_ = (
char *)
malloc(whitespace_length_ + 4);
100 char *
p = whitespace_;
101 for (
size_t i = 0; i < whitespace_length_; i += 4) {
115 const char *typespaths[] = {
123 const char* typesfilenames[] = {
133 for (
size_t j = 0;
j <
sizeof(typesfilenames) /
sizeof(typesfilenames[0]);
j++) {
135 for (
size_t i = 0; i <
sizeof(typespaths) /
sizeof(typespaths[0]); i++) {
137 sprintf(filename,
"%s/%s", typespaths[i], typesfilenames[
j]);
140 typesLength_[
j] = (size_t)
ftell(fp);
142 types_[
j] = (
char*)
malloc(typesLength_[
j] + 1);
143 ASSERT_EQ(typesLength_[
j],
fread(types_[
j], 1, typesLength_[
j], fp));
144 types_[
j][typesLength_[
j]] =
'\0';
153 virtual void TearDown() {
158 for (
size_t i = 0; i < 7; i++) {
165 PerfTest(
const PerfTest&);
166 PerfTest& operator=(
const PerfTest&);
169 const char* filename_;
173 size_t whitespace_length_;
175 size_t typesLength_[7];
177 static const size_t kTrialCount = 1000;
180 #endif // __cplusplus 182 #endif // PERFTEST_H_ #define ftell
Definition: file_stream_transforms.h:54
#define SEEK_END
Definition: zconf.h:440
GLsizei const GLuint * paths
Definition: glext.h:12624
#define fclose
Definition: file_stream_transforms.h:53
#define SEEK_SET
Definition: zconf.h:438
int sprintf(char *s, const char *format,...)
Definition: compat_ctype.c:81
GLfloat GLfloat p
Definition: glext.h:9809
#define FILE
Definition: file_stream_transforms.h:35
GLint j
Definition: nx_glsym.h:307
#define fread
Definition: file_stream_transforms.h:56
#define fopen
Definition: file_stream_transforms.h:52
#define fseek
Definition: file_stream_transforms.h:55