OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/safe_browsing/prefix_set.h" | 5 #include "chrome/browser/safe_browsing/prefix_set.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
23 // Constants for the v1 format. | 23 // Constants for the v1 format. |
24 static const size_t kMagicOffset = 0 * sizeof(uint32); | 24 static const size_t kMagicOffset = 0 * sizeof(uint32); |
25 static const size_t kVersionOffset = 1 * sizeof(uint32); | 25 static const size_t kVersionOffset = 1 * sizeof(uint32); |
26 static const size_t kIndexSizeOffset = 2 * sizeof(uint32); | 26 static const size_t kIndexSizeOffset = 2 * sizeof(uint32); |
27 static const size_t kDeltasSizeOffset = 3 * sizeof(uint32); | 27 static const size_t kDeltasSizeOffset = 3 * sizeof(uint32); |
28 static const size_t kPayloadOffset = 4 * sizeof(uint32); | 28 static const size_t kPayloadOffset = 4 * sizeof(uint32); |
29 | 29 |
30 // Generate a set of random prefixes to share between tests. For | 30 // Generate a set of random prefixes to share between tests. For |
31 // most tests this generation was a large fraction of the test time. | 31 // most tests this generation was a large fraction of the test time. |
32 static void SetUpTestCase() { | 32 static void SetUpTestCase() { |
33 for (size_t i = 0; i < 50000; ++i) { | 33 for (size_t i = 0; i < 5000; ++i) { |
Scott Hess - ex-Googler
2013/11/05 03:04:58
In theory, this many values should be able to spre
Paweł Hajdan Jr.
2013/11/05 03:10:06
I'm not sure now - it's definitely about the speed
Scott Hess - ex-Googler
2013/11/05 03:17:24
for (size_t i = 0; i < 500; ++i) {
SBPrefix a[10
Paweł Hajdan Jr.
2013/11/05 22:42:26
I've tried it and it doesn't help in a meaningful
Scott Hess - ex-Googler
2013/11/06 00:47:14
495 _seconds_? Normally the entire PrefixSetTest.
| |
34 const SBPrefix prefix = static_cast<SBPrefix>(base::RandUint64()); | 34 const SBPrefix prefix = static_cast<SBPrefix>(base::RandUint64()); |
35 shared_prefixes_.push_back(prefix); | 35 shared_prefixes_.push_back(prefix); |
36 } | 36 } |
37 | 37 |
38 // Sort for use with PrefixSet constructor. | 38 // Sort for use with PrefixSet constructor. |
39 std::sort(shared_prefixes_.begin(), shared_prefixes_.end()); | 39 std::sort(shared_prefixes_.begin(), shared_prefixes_.end()); |
40 } | 40 } |
41 | 41 |
42 // Check that all elements of |prefixes| are in |prefix_set|, and | 42 // Check that all elements of |prefixes| are in |prefix_set|, and |
43 // that nearby elements are not (for lack of a more sensible set of | 43 // that nearby elements are not (for lack of a more sensible set of |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
459 file_util::ScopedFILE file(file_util::OpenFile(filename, "ab")); | 459 file_util::ScopedFILE file(file_util::OpenFile(filename, "ab")); |
460 const char buf[] = "im in ur base, killing ur d00dz."; | 460 const char buf[] = "im in ur base, killing ur d00dz."; |
461 ASSERT_EQ(strlen(buf), fwrite(buf, 1, strlen(buf), file.get())); | 461 ASSERT_EQ(strlen(buf), fwrite(buf, 1, strlen(buf), file.get())); |
462 file.reset(); | 462 file.reset(); |
463 scoped_ptr<safe_browsing::PrefixSet> | 463 scoped_ptr<safe_browsing::PrefixSet> |
464 prefix_set(safe_browsing::PrefixSet::LoadFile(filename)); | 464 prefix_set(safe_browsing::PrefixSet::LoadFile(filename)); |
465 ASSERT_FALSE(prefix_set.get()); | 465 ASSERT_FALSE(prefix_set.get()); |
466 } | 466 } |
467 | 467 |
468 } // namespace | 468 } // namespace |
OLD | NEW |