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

Side by Side Diff: base/json/json_perftest.cc

Issue 2664753002: Remove base::StringValue (Closed)
Patch Set: Rebase Created 3 years, 9 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 | « base/json/json_parser.cc ('k') | base/json/json_writer_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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "base/json/json_reader.h" 5 #include "base/json/json_reader.h"
6 #include "base/json/json_writer.h" 6 #include "base/json/json_writer.h"
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "testing/perf/perf_test.h" 11 #include "testing/perf/perf_test.h"
12 12
13 namespace base { 13 namespace base {
14 14
15 namespace { 15 namespace {
16 // Generates a simple dictionary value with simple data types, a string and a 16 // Generates a simple dictionary value with simple data types, a string and a
17 // list. 17 // list.
18 std::unique_ptr<DictionaryValue> GenerateDict() { 18 std::unique_ptr<DictionaryValue> GenerateDict() {
19 auto root = MakeUnique<DictionaryValue>(); 19 auto root = MakeUnique<DictionaryValue>();
20 root->SetDouble("Double", 3.141); 20 root->SetDouble("Double", 3.141);
21 root->SetBoolean("Bool", true); 21 root->SetBoolean("Bool", true);
22 root->SetInteger("Int", 42); 22 root->SetInteger("Int", 42);
23 root->SetString("String", "Foo"); 23 root->SetString("String", "Foo");
24 24
25 auto list = MakeUnique<ListValue>(); 25 auto list = MakeUnique<ListValue>();
26 list->Set(0, MakeUnique<Value>(2.718)); 26 list->Set(0, MakeUnique<Value>(2.718));
27 list->Set(1, MakeUnique<Value>(false)); 27 list->Set(1, MakeUnique<Value>(false));
28 list->Set(2, MakeUnique<Value>(123)); 28 list->Set(2, MakeUnique<Value>(123));
29 list->Set(3, MakeUnique<StringValue>("Bar")); 29 list->Set(3, MakeUnique<Value>("Bar"));
30 root->Set("List", std::move(list)); 30 root->Set("List", std::move(list));
31 31
32 return root; 32 return root;
33 } 33 }
34 34
35 // Generates a tree-like dictionary value with a size of O(breadth ** depth). 35 // Generates a tree-like dictionary value with a size of O(breadth ** depth).
36 std::unique_ptr<DictionaryValue> GenerateLayeredDict(int breadth, int depth) { 36 std::unique_ptr<DictionaryValue> GenerateLayeredDict(int breadth, int depth) {
37 if (depth == 1) 37 if (depth == 1)
38 return GenerateDict(); 38 return GenerateDict();
39 39
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 TEST_F(JSONPerfTest, StressTest) { 76 TEST_F(JSONPerfTest, StressTest) {
77 for (int i = 0; i < 4; ++i) { 77 for (int i = 0; i < 4; ++i) {
78 for (int j = 0; j < 12; ++j) { 78 for (int j = 0; j < 12; ++j) {
79 TestWriteAndRead(i + 1, j + 1); 79 TestWriteAndRead(i + 1, j + 1);
80 } 80 }
81 } 81 }
82 } 82 }
83 83
84 } // namespace base 84 } // namespace base
OLDNEW
« no previous file with comments | « base/json/json_parser.cc ('k') | base/json/json_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698