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

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

Issue 1120006: detect preferences errors (Closed)
Patch Set: changes from review Created 10 years, 8 months 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
« no previous file with comments | « chrome/common/json_value_serializer.cc ('k') | chrome/common/json_value_serializer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // using 3 sample strings for both the current decoder and jsoncpp's decoder. 46 // using 3 sample strings for both the current decoder and jsoncpp's decoder.
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 JSONStringValueSerializer reader(test_cases_[j]); 55 JSONStringValueSerializer reader(test_cases_[j]);
56 scoped_ptr<Value> root(reader.Deserialize(NULL)); 56 scoped_ptr<Value> root(reader.Deserialize(NULL, NULL));
57 ASSERT_TRUE(root.get()); 57 ASSERT_TRUE(root.get());
58 } 58 }
59 } 59 }
60 chrome_timer.Done(); 60 chrome_timer.Done();
61 } 61 }
62 62
63 TEST_F(JSONValueSerializerTests, CompactWriting) { 63 TEST_F(JSONValueSerializerTests, CompactWriting) {
64 printf("\n"); 64 printf("\n");
65 const int kIterations = 100000; 65 const int kIterations = 100000;
66 // Convert test cases to Value objects. 66 // Convert test cases to Value objects.
67 std::vector<Value*> test_cases; 67 std::vector<Value*> test_cases;
68 for (size_t i = 0; i < test_cases_.size(); ++i) { 68 for (size_t i = 0; i < test_cases_.size(); ++i) {
69 JSONStringValueSerializer reader(test_cases_[i]); 69 JSONStringValueSerializer reader(test_cases_[i]);
70 Value* root = reader.Deserialize(NULL); 70 Value* root = reader.Deserialize(NULL, NULL);
71 ASSERT_TRUE(root); 71 ASSERT_TRUE(root);
72 test_cases.push_back(root); 72 test_cases.push_back(root);
73 } 73 }
74 74
75 PerfTimeLogger chrome_timer("chrome"); 75 PerfTimeLogger chrome_timer("chrome");
76 for (int i = 0; i < kIterations; ++i) { 76 for (int i = 0; i < kIterations; ++i) {
77 for (size_t j = 0; j < test_cases.size(); ++j) { 77 for (size_t j = 0; j < test_cases.size(); ++j) {
78 std::string json; 78 std::string json;
79 JSONStringValueSerializer reader(&json); 79 JSONStringValueSerializer reader(&json);
80 ASSERT_TRUE(reader.Serialize(*test_cases[j])); 80 ASSERT_TRUE(reader.Serialize(*test_cases[j]));
81 } 81 }
82 } 82 }
83 chrome_timer.Done(); 83 chrome_timer.Done();
84 84
85 // Clean up test cases. 85 // Clean up test cases.
86 for (size_t i = 0; i < test_cases.size(); ++i) { 86 for (size_t i = 0; i < test_cases.size(); ++i) {
87 delete test_cases[i]; 87 delete test_cases[i];
88 test_cases[i] = NULL; 88 test_cases[i] = NULL;
89 } 89 }
90 } 90 }
OLDNEW
« no previous file with comments | « chrome/common/json_value_serializer.cc ('k') | chrome/common/json_value_serializer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698