OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This test performs a series false positive checks using a list of URLs | 5 // This test performs a series false positive checks using a list of URLs |
6 // against a known set of SafeBrowsing data. | 6 // against a known set of SafeBrowsing data. |
7 // | 7 // |
8 // It uses a normal SafeBrowsing database to create a bloom filter where it | 8 // It uses a normal SafeBrowsing database to create a bloom filter where it |
9 // looks up all the URLs in the url file. A URL that has a prefix found in the | 9 // looks up all the URLs in the url file. A URL that has a prefix found in the |
10 // bloom filter and found in the database is considered a hit: a valid lookup | 10 // bloom filter and found in the database is considered a hit: a valid lookup |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // database: A normal SafeBrowsing database. | 49 // database: A normal SafeBrowsing database. |
50 // urls: A text file containing a list of URLs, one per line. If the option | 50 // urls: A text file containing a list of URLs, one per line. If the option |
51 // --filter-csv is specified, the format of each line in the file is | 51 // --filter-csv is specified, the format of each line in the file is |
52 // <url>,<weight> where weight is an integer indicating the number of | 52 // <url>,<weight> where weight is an integer indicating the number of |
53 // unique views for the URL. | 53 // unique views for the URL. |
54 | 54 |
55 #include <algorithm> | 55 #include <algorithm> |
56 #include <fstream> | 56 #include <fstream> |
57 #include <vector> | 57 #include <vector> |
58 | 58 |
59 #include "app/sql/statement.h" | |
60 #include "base/command_line.h" | 59 #include "base/command_line.h" |
61 #include "base/file_path.h" | 60 #include "base/file_path.h" |
62 #include "base/file_util.h" | 61 #include "base/file_util.h" |
63 #include "base/logging.h" | 62 #include "base/logging.h" |
64 #include "base/memory/scoped_ptr.h" | 63 #include "base/memory/scoped_ptr.h" |
65 #include "base/path_service.h" | 64 #include "base/path_service.h" |
66 #include "base/rand_util.h" | 65 #include "base/rand_util.h" |
67 #include "base/string_number_conversions.h" | 66 #include "base/string_number_conversions.h" |
68 #include "base/string_util.h" | 67 #include "base/string_util.h" |
69 #include "base/time.h" | 68 #include "base/time.h" |
70 #include "crypto/sha2.h" | |
71 #include "chrome/browser/safe_browsing/bloom_filter.h" | 69 #include "chrome/browser/safe_browsing/bloom_filter.h" |
72 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 70 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
73 #include "chrome/common/chrome_paths.h" | 71 #include "chrome/common/chrome_paths.h" |
| 72 #include "crypto/sha2.h" |
74 #include "googleurl/src/gurl.h" | 73 #include "googleurl/src/gurl.h" |
| 74 #include "sql/statement.h" |
75 #include "testing/gtest/include/gtest/gtest.h" | 75 #include "testing/gtest/include/gtest/gtest.h" |
76 | 76 |
77 using base::Time; | 77 using base::Time; |
78 using base::TimeDelta; | 78 using base::TimeDelta; |
79 | 79 |
80 namespace { | 80 namespace { |
81 | 81 |
82 // Command line flags. | 82 // Command line flags. |
83 const char kFilterVerbose[] = "filter-verbose"; | 83 const char kFilterVerbose[] = "filter-verbose"; |
84 const char kFilterStart[] = "filter-start"; | 84 const char kFilterStart[] = "filter-start"; |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 | 354 |
355 std::cout << "Time results for checks: " << num_checks | 355 std::cout << "Time results for checks: " << num_checks |
356 << ", prefixes: " << prefix_list.size() | 356 << ", prefixes: " << prefix_list.size() |
357 << ", populate time (ms): " << populate.InMilliseconds() | 357 << ", populate time (ms): " << populate.InMilliseconds() |
358 << ", check time (ms): " << check.InMilliseconds() | 358 << ", check time (ms): " << check.InMilliseconds() |
359 << ", hits: " << hits | 359 << ", hits: " << hits |
360 << ", per-populate (us): " << time_per_insert | 360 << ", per-populate (us): " << time_per_insert |
361 << ", per-check (us): " << time_per_check | 361 << ", per-check (us): " << time_per_check |
362 << std::endl; | 362 << std::endl; |
363 } | 363 } |
OLD | NEW |