mirror of
https://github.com/Tencent/rapidjson.git
synced 2025-10-21 15:51:47 +02:00
Initial version (0.1)
git-svn-id: https://rapidjson.googlecode.com/svn/trunk@2 c5894555-1306-4e8d-425f-1f6f381ee07c
This commit is contained in:
57
test/perftest/jsoncpptest.cpp
Normal file
57
test/perftest/jsoncpptest.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "perftest.h"
|
||||
|
||||
#if TEST_JSONCPP
|
||||
|
||||
#include "jsoncpp/src/lib_json/json_reader.cpp"
|
||||
#include "jsoncpp/src/lib_json/json_value.cpp"
|
||||
#include "jsoncpp/src/lib_json/json_writer.cpp"
|
||||
|
||||
using namespace Json;
|
||||
|
||||
class JsonCpp : public PerfTest {
|
||||
public:
|
||||
virtual void SetUp() {
|
||||
PerfTest::SetUp();
|
||||
Reader reader;
|
||||
ASSERT_TRUE(reader.parse(json_, root_));
|
||||
}
|
||||
|
||||
protected:
|
||||
Value root_;
|
||||
};
|
||||
|
||||
TEST_F(JsonCpp, ReaderParse) {
|
||||
for (int i = 0; i < kTrialCount; i++) {
|
||||
Value root;
|
||||
Reader reader;
|
||||
ASSERT_TRUE(reader.parse(json_, root));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(JsonCpp, FastWriter) {
|
||||
for (int i = 0; i < kTrialCount; i++) {
|
||||
FastWriter writer;
|
||||
std::string str = writer.write(root_);
|
||||
//if (i == 0)
|
||||
// std::cout << str.length() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(JsonCpp, StyledWriter) {
|
||||
for (int i = 0; i < kTrialCount; i++) {
|
||||
StyledWriter writer;
|
||||
std::string str = writer.write(root_);
|
||||
//if (i == 0)
|
||||
// std::cout << str.length() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(JsonCpp, Whitespace) {
|
||||
for (int i = 0; i < kTrialCount; i++) {
|
||||
Value root;
|
||||
Reader reader;
|
||||
ASSERT_TRUE(reader.parse(whitespace_, root));
|
||||
}
|
||||
}
|
||||
|
||||
#endif // TEST_JSONCPP
|
Reference in New Issue
Block a user