Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(853)

Side by Side Diff: chrome/common/json_value_serializer_perftest.cc

Issue 13169: Add error messages to JSONReader and friends. This required a bit of refactor... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector> 5 #include <vector>
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/perftimer.h" 9 #include "base/perftimer.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 TEST_F(JSONValueSerializerTests, Reading) { 47 TEST_F(JSONValueSerializerTests, Reading) {
48 printf("\n"); 48 printf("\n");
49 const int kIterations = 100000; 49 const int kIterations = 100000;
50 50
51 // Test chrome json implementation 51 // Test chrome json implementation
52 PerfTimeLogger chrome_timer("chrome"); 52 PerfTimeLogger chrome_timer("chrome");
53 for (int i = 0; i < kIterations; ++i) { 53 for (int i = 0; i < kIterations; ++i) {
54 for (size_t j = 0; j < test_cases_.size(); ++j) { 54 for (size_t j = 0; j < test_cases_.size(); ++j) {
55 Value* root = NULL; 55 Value* root = NULL;
56 JSONStringValueSerializer reader(test_cases_[j]); 56 JSONStringValueSerializer reader(test_cases_[j]);
57 ASSERT_TRUE(reader.Deserialize(&root)); 57 ASSERT_TRUE(reader.Deserialize(&root, NULL));
58 delete root; 58 delete root;
59 } 59 }
60 } 60 }
61 chrome_timer.Done(); 61 chrome_timer.Done();
62 } 62 }
63 63
64 TEST_F(JSONValueSerializerTests, CompactWriting) { 64 TEST_F(JSONValueSerializerTests, CompactWriting) {
65 printf("\n"); 65 printf("\n");
66 const int kIterations = 100000; 66 const int kIterations = 100000;
67 // Convert test cases to Value objects. 67 // Convert test cases to Value objects.
68 std::vector<Value*> test_cases; 68 std::vector<Value*> test_cases;
69 for (size_t i = 0; i < test_cases_.size(); ++i) { 69 for (size_t i = 0; i < test_cases_.size(); ++i) {
70 Value* root = NULL; 70 Value* root = NULL;
71 JSONStringValueSerializer reader(test_cases_[i]); 71 JSONStringValueSerializer reader(test_cases_[i]);
72 ASSERT_TRUE(reader.Deserialize(&root)); 72 ASSERT_TRUE(reader.Deserialize(&root, NULL));
73 test_cases.push_back(root); 73 test_cases.push_back(root);
74 } 74 }
75 75
76 PerfTimeLogger chrome_timer("chrome"); 76 PerfTimeLogger chrome_timer("chrome");
77 for (int i = 0; i < kIterations; ++i) { 77 for (int i = 0; i < kIterations; ++i) {
78 for (size_t j = 0; j < test_cases.size(); ++j) { 78 for (size_t j = 0; j < test_cases.size(); ++j) {
79 std::string json; 79 std::string json;
80 JSONStringValueSerializer reader(&json); 80 JSONStringValueSerializer reader(&json);
81 ASSERT_TRUE(reader.Serialize(*test_cases[j])); 81 ASSERT_TRUE(reader.Serialize(*test_cases[j]));
82 } 82 }
83 } 83 }
84 chrome_timer.Done(); 84 chrome_timer.Done();
85 85
86 // Clean up test cases. 86 // Clean up test cases.
87 for (size_t i = 0; i < test_cases.size(); ++i) { 87 for (size_t i = 0; i < test_cases.size(); ++i) {
88 delete test_cases[i]; 88 delete test_cases[i];
89 test_cases[i] = NULL; 89 test_cases[i] = NULL;
90 } 90 }
91 } 91 }
92 92
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698