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

Side by Side Diff: tests/ChecksumTest.cpp

Issue 1436973003: Switch uses of SkChecksum::Compute to Murmur3. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix Created 5 years, 1 month 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 | « src/gpu/GrResourceCache.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkChecksum.h" 8 #include "SkChecksum.h"
9 #include "SkRandom.h" 9 #include "SkRandom.h"
10 #include "Test.h" 10 #include "Test.h"
11 11
12 12
13 // Murmur3 has an optional third seed argument, so we wrap it to fit a uniform t ype. 13 // Murmur3 has an optional third seed argument, so we wrap it to fit a uniform t ype.
14 static uint32_t murmur_noseed(const uint32_t* d, size_t l) { return SkChecksum:: Murmur3(d, l); } 14 static uint32_t murmur_noseed(const uint32_t* d, size_t l) { return SkChecksum:: Murmur3(d, l); }
15 15
16 #define ASSERT(x) REPORTER_ASSERT(r, x) 16 #define ASSERT(x) REPORTER_ASSERT(r, x)
17 17
18 DEF_TEST(Checksum, r) { 18 DEF_TEST(Checksum, r) {
19 // Algorithms to test. They're currently all uint32_t(const uint32_t*, size _t). 19 // Algorithms to test. They're currently all uint32_t(const uint32_t*, size _t).
20 typedef uint32_t(*algorithmProc)(const uint32_t*, size_t); 20 typedef uint32_t(*algorithmProc)(const uint32_t*, size_t);
21 const algorithmProc kAlgorithms[] = { &SkChecksum::Compute, &murmur_noseed } ; 21 const algorithmProc kAlgorithms[] = { &murmur_noseed };
22 22
23 // Put 128 random bytes into two identical buffers. Any multiple of 4 will do. 23 // Put 128 random bytes into two identical buffers. Any multiple of 4 will do.
24 const size_t kBytes = SkAlign4(128); 24 const size_t kBytes = SkAlign4(128);
25 SkRandom rand; 25 SkRandom rand;
26 uint32_t data[kBytes/4], tweaked[kBytes/4]; 26 uint32_t data[kBytes/4], tweaked[kBytes/4];
27 for (size_t i = 0; i < SK_ARRAY_COUNT(tweaked); ++i) { 27 for (size_t i = 0; i < SK_ARRAY_COUNT(tweaked); ++i) {
28 data[i] = tweaked[i] = rand.nextU(); 28 data[i] = tweaked[i] = rand.nextU();
29 } 29 }
30 30
31 // Test each algorithm. 31 // Test each algorithm.
(...skipping 24 matching lines...) Expand all
56 ASSERT(SkGoodHash()((uint32_t)4) == 614249093); // (Ditto) 56 ASSERT(SkGoodHash()((uint32_t)4) == 614249093); // (Ditto)
57 57
58 // None of these are 4 byte sized, so they use SkChecksum::Murmur3, not SkCh ecksum::Mix. 58 // None of these are 4 byte sized, so they use SkChecksum::Murmur3, not SkCh ecksum::Mix.
59 ASSERT(SkGoodHash()((uint64_t)4) == 3491892518); 59 ASSERT(SkGoodHash()((uint64_t)4) == 3491892518);
60 ASSERT(SkGoodHash()((uint16_t)4) == 899251846); 60 ASSERT(SkGoodHash()((uint16_t)4) == 899251846);
61 ASSERT(SkGoodHash()( (uint8_t)4) == 962700458); 61 ASSERT(SkGoodHash()( (uint8_t)4) == 962700458);
62 62
63 // Tests SkString is correctly specialized. 63 // Tests SkString is correctly specialized.
64 ASSERT(SkGoodHash()(SkString("Hi")) == 55667557); 64 ASSERT(SkGoodHash()(SkString("Hi")) == 55667557);
65 } 65 }
OLDNEW
« no previous file with comments | « src/gpu/GrResourceCache.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698