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

Side by Side Diff: net/base/cookie_monster_perftest.cc

Issue 3070001: Fixes targeting the unique creation times invariant in the CookieMonster: (Closed)
Patch Set: Made creation times in perftest unique. Created 10 years, 5 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "net/base/cookie_monster.h"
5 #include "base/perftimer.h" 6 #include "base/perftimer.h"
6 #include "base/string_util.h" 7 #include "base/string_util.h"
7 #include "net/base/cookie_monster.h" 8 #include "googleurl/src/gurl.h"
9 #include "net/base/cookie_monster_store_test.h"
8 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
9 #include "googleurl/src/gurl.h"
10 11
11 namespace { 12 namespace {
12 class ParsedCookieTest : public testing::Test { }; 13 class ParsedCookieTest : public testing::Test { };
13 class CookieMonsterTest : public testing::Test { }; 14 class CookieMonsterTest : public testing::Test { };
14 } 15 }
15 16
16 static const int kNumCookies = 20000; 17 static const int kNumCookies = 20000;
17 static const char kCookieLine[] = "A = \"b=;\\\"\" ;secure;;;"; 18 static const char kCookieLine[] = "A = \"b=;\\\"\" ;secure;;;";
18 19
19 TEST(ParsedCookieTest, TestParseCookies) { 20 TEST(ParsedCookieTest, TestParseCookies) {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 it != gurl_list.end(); it++) { 155 it != gurl_list.end(); it++) {
155 EXPECT_TRUE(cm->SetCookie(*it, StringPrintf("a%03d=b", i))); 156 EXPECT_TRUE(cm->SetCookie(*it, StringPrintf("a%03d=b", i)));
156 } 157 }
157 } 158 }
158 PerfTimeLogger timer2("Cookie_monster_query_domain_line"); 159 PerfTimeLogger timer2("Cookie_monster_query_domain_line");
159 for (int i = 0; i < kNumCookies; i++) { 160 for (int i = 0; i < kNumCookies; i++) {
160 cm->GetCookies(probe_gurl); 161 cm->GetCookies(probe_gurl);
161 } 162 }
162 timer2.Done(); 163 timer2.Done();
163 } 164 }
165
166 TEST(CookieMonsterTest, TestImport) {
167 scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore);
168 std::vector<net::CookieMonster::KeyedCanonicalCookie> initial_cookies;
169
170 // We want to setup a fairly large backing store, with 300 domains of 50
171 // cookies each. Creation times must be unique.
172 int64 time_tick(base::Time::Now().ToInternalValue());
173
174 for (int domain_num = 0; domain_num < 300; domain_num++) {
175 std::string domain_name(StringPrintf(".Domain_%d.com", domain_num));
176 std::string gurl("www" + domain_name);
177 for (int cookie_num = 0; cookie_num < 50; cookie_num++) {
178 std::string cookie_line(StringPrintf("Cookie_%d=1; Path=/", cookie_num));
179 AddKeyedCookieToList(gurl, cookie_line,
180 base::Time::FromInternalValue(time_tick++),
181 &initial_cookies);
182 }
183 }
184
185 store->SetLoadExpectation(true, initial_cookies);
186
187 scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(store, NULL));
188
189 // Import will happen on first access.
190 GURL gurl("www.google.com");
191 net::CookieOptions options;
192 PerfTimeLogger timer("Cookie_monster_import_from_store");
193 cm->GetCookiesWithOptions(gurl, options);
194 timer.Done();
195 }
196
197
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698