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

Side by Side Diff: chrome/browser/safe_browsing/database_perftest.cc

Issue 19610: Safe browsing cleanup:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « base/file_util_win.cc ('k') | chrome/browser/safe_browsing/safe_browsing_database.h » ('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 <stdio.h> 5 #include <stdio.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 7
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 10
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 382
383 383
384 class SafeBrowsingDatabaseTest { 384 class SafeBrowsingDatabaseTest {
385 public: 385 public:
386 SafeBrowsingDatabaseTest(const FilePath& filename) { 386 SafeBrowsingDatabaseTest(const FilePath& filename) {
387 logging::InitLogging( 387 logging::InitLogging(
388 NULL, logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, 388 NULL, logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG,
389 logging::LOCK_LOG_FILE, 389 logging::LOCK_LOG_FILE,
390 logging::DELETE_OLD_LOG_FILE); 390 logging::DELETE_OLD_LOG_FILE);
391 391
392 std::wstring tmp_path; 392 FilePath tmp_path;
393 PathService::Get(base::DIR_TEMP, &tmp_path); 393 PathService::Get(base::DIR_TEMP, &tmp_path);
394 path_ = FilePath::FromWStringHack(tmp_path); 394 path_ = tmp_path.Append(filename);
395 path_ = path_.Append(filename);
396 } 395 }
397 396
398 void Create(int size) { 397 void Create(int size) {
399 file_util::Delete(path_, false); 398 file_util::Delete(path_, false);
400 399
401 scoped_ptr<SafeBrowsingDatabase> database(SafeBrowsingDatabase::Create()); 400 scoped_ptr<SafeBrowsingDatabase> database(SafeBrowsingDatabase::Create());
402 database->SetSynchronous(); 401 database->SetSynchronous();
403 EXPECT_TRUE(database->Init(path_.ToWStringHack(), NULL)); 402 EXPECT_TRUE(database->Init(path_, NULL));
404 403
405 int chunk_id = 0; 404 int chunk_id = 0;
406 int total_host_keys = size; 405 int total_host_keys = size;
407 int host_keys_per_chunk = 100; 406 int host_keys_per_chunk = 100;
408 407
409 std::deque<SBChunk>* chunks = new std::deque<SBChunk>; 408 std::deque<SBChunk>* chunks = new std::deque<SBChunk>;
410 409
411 for (int i = 0; i < total_host_keys / host_keys_per_chunk; ++i) { 410 for (int i = 0; i < total_host_keys / host_keys_per_chunk; ++i) {
412 chunks->push_back(SBChunk()); 411 chunks->push_back(SBChunk());
413 chunks->back().chunk_number = ++chunk_id; 412 chunks->back().chunk_number = ++chunk_id;
(...skipping 12 matching lines...) Expand all
426 425
427 database->InsertChunks("goog-malware", chunks); 426 database->InsertChunks("goog-malware", chunks);
428 } 427 }
429 428
430 void Read(bool use_bloom_filter) { 429 void Read(bool use_bloom_filter) {
431 int keys_to_read = 500; 430 int keys_to_read = 500;
432 file_util::EvictFileFromSystemCache(path_); 431 file_util::EvictFileFromSystemCache(path_);
433 432
434 scoped_ptr<SafeBrowsingDatabase> database(SafeBrowsingDatabase::Create()); 433 scoped_ptr<SafeBrowsingDatabase> database(SafeBrowsingDatabase::Create());
435 database->SetSynchronous(); 434 database->SetSynchronous();
436 EXPECT_TRUE(database->Init(path_.ToWStringHack(), NULL)); 435 EXPECT_TRUE(database->Init(path_, NULL));
437 436
438 PerfTimer total_timer; 437 PerfTimer total_timer;
439 int64 db_ms = 0; 438 int64 db_ms = 0;
440 int keys_from_db = 0; 439 int keys_from_db = 0;
441 for (int i = 0; i < keys_to_read; ++i) { 440 for (int i = 0; i < keys_to_read; ++i) {
442 int key = base::RandInt(std::numeric_limits<int>::min(), 441 int key = base::RandInt(std::numeric_limits<int>::min(),
443 std::numeric_limits<int>::max()); 442 std::numeric_limits<int>::max());
444 443
445 std::string url = StringPrintf("http://www.%d.com/blah.html", key); 444 std::string url = StringPrintf("http://www.%d.com/blah.html", key);
446 445
(...skipping 21 matching lines...) Expand all
468 int64 total_ms = total_timer.Elapsed().InMilliseconds(); 467 int64 total_ms = total_timer.Elapsed().InMilliseconds();
469 468
470 DLOG(INFO) << path_.BaseName().value() << " read " << keys_to_read << 469 DLOG(INFO) << path_.BaseName().value() << " read " << keys_to_read <<
471 " entries in " << total_ms << " ms. " << keys_from_db << 470 " entries in " << total_ms << " ms. " << keys_from_db <<
472 " keys were read from the db, with average read taking " << 471 " keys were read from the db, with average read taking " <<
473 db_ms / keys_from_db << " ms"; 472 db_ms / keys_from_db << " ms";
474 } 473 }
475 474
476 void BuildBloomFilter() { 475 void BuildBloomFilter() {
477 file_util::EvictFileFromSystemCache(path_); 476 file_util::EvictFileFromSystemCache(path_);
478 file_util::Delete(SafeBrowsingDatabase::BloomFilterFilename( 477 file_util::Delete(SafeBrowsingDatabase::BloomFilterFilename(path_), false);
479 path_.ToWStringHack()), false);
480 478
481 PerfTimer total_timer; 479 PerfTimer total_timer;
482 480
483 scoped_ptr<SafeBrowsingDatabase> database(SafeBrowsingDatabase::Create()); 481 scoped_ptr<SafeBrowsingDatabase> database(SafeBrowsingDatabase::Create());
484 database->SetSynchronous(); 482 database->SetSynchronous();
485 EXPECT_TRUE(database->Init(path_.ToWStringHack(), NULL)); 483 EXPECT_TRUE(database->Init(path_, NULL));
486 484
487 int64 total_ms = total_timer.Elapsed().InMilliseconds(); 485 int64 total_ms = total_timer.Elapsed().InMilliseconds();
488 486
489 DLOG(INFO) << path_.BaseName().value() << 487 DLOG(INFO) << path_.BaseName().value() <<
490 " built bloom filter in " << total_ms << " ms."; 488 " built bloom filter in " << total_ms << " ms.";
491 } 489 }
492 490
493 private: 491 private:
494 FilePath path_; 492 FilePath path_;
495 }; 493 };
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 // Test how long bloom filter creation takes. 535 // Test how long bloom filter creation takes.
538 TEST(SafeBrowsingDatabase, DISABLED_BuildBloomFilter250K) { 536 TEST(SafeBrowsingDatabase, DISABLED_BuildBloomFilter250K) {
539 SafeBrowsingDatabaseTest db(FilePath(FILE_PATH_LITERAL("SafeBrowsing250K"))); 537 SafeBrowsingDatabaseTest db(FilePath(FILE_PATH_LITERAL("SafeBrowsing250K")));
540 db.BuildBloomFilter(); 538 db.BuildBloomFilter();
541 } 539 }
542 540
543 TEST(SafeBrowsingDatabase, DISABLED_BuildBloomFilter500K) { 541 TEST(SafeBrowsingDatabase, DISABLED_BuildBloomFilter500K) {
544 SafeBrowsingDatabaseTest db(FilePath(FILE_PATH_LITERAL("SafeBrowsing500K"))); 542 SafeBrowsingDatabaseTest db(FilePath(FILE_PATH_LITERAL("SafeBrowsing500K")));
545 db.BuildBloomFilter(); 543 db.BuildBloomFilter();
546 } 544 }
OLDNEW
« no previous file with comments | « base/file_util_win.cc ('k') | chrome/browser/safe_browsing/safe_browsing_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698