Commit e600eae
committed
Improve performance by improving the handling of hashes
Performance is improved in the following ways:
1. Eliminate Hash.ComputeHash() that returns a string, and
Hash.Sum() that converts the string to an array of hash bytes
2. Avoid the use of Enumerable.Skip() and Enumerable.Take()
3. Avoid the use of Array.Reverse() on little-endian architectures
Change library to use HashAlgorithm directly. Remove Hash.cs, Hash128.cs
and their corresponding tests.
Add Utils.HashBytesToUInt32() and Utils.HashBytesToUInt64() functions
that convert a set of .NET hash bytes into a uint or ulong regardless
of the endianness of the architecture.
Fix Utils.HashKernel128() to conform to how HashKernel() works,
and fix corresponding unit tests.
Add TestProbabilisticDataStructures.TestHashKernelFNV1()
that confirms that the HashKernel() function returns
the same values as the HashKernel() function in
https://github.com/tylertreat/BoomFilters running in Go.
Move the original Hash.ComputeHash() that returns a string
to Utils.ComputeHashAsString(). This function is no longer
used by the library, but the unit tests that use it remain.1 parent 630fced commit e600eae
File tree
10 files changed
+188
-414
lines changed- ProbabilisticDataStructures
- TestProbabilisticDataStructures
10 files changed
+188
-414
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
387 | | - | |
| 387 | + | |
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
394 | 394 | | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | 395 | | |
409 | 396 | | |
410 | 397 | | |
411 | 398 | | |
412 | 399 | | |
413 | 400 | | |
414 | 401 | | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
| 402 | + | |
| 403 | + | |
419 | 404 | | |
420 | 405 | | |
421 | 406 | | |
| |||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
| 211 | + | |
| 212 | + | |
215 | 213 | | |
216 | 214 | | |
217 | 215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
| 164 | + | |
| 165 | + | |
168 | 166 | | |
169 | 167 | | |
170 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
51 | | - | |
| 52 | + | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
58 | | - | |
59 | | - | |
60 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
61 | 75 | | |
62 | | - | |
63 | | - | |
| 76 | + | |
| 77 | + | |
64 | 78 | | |
65 | 79 | | |
66 | 80 | | |
| |||
73 | 87 | | |
74 | 88 | | |
75 | 89 | | |
76 | | - | |
77 | | - | |
| 90 | + | |
78 | 91 | | |
79 | | - | |
80 | | - | |
| 92 | + | |
| 93 | + | |
81 | 94 | | |
82 | 95 | | |
83 | 96 | | |
84 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
85 | 106 | | |
86 | | - | |
87 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
88 | 113 | | |
89 | | - | |
90 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
91 | 133 | | |
92 | 134 | | |
93 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
94 | 141 | | |
95 | | - | |
96 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
97 | 154 | | |
98 | | - | |
99 | | - | |
| 155 | + | |
| 156 | + | |
100 | 157 | | |
101 | 158 | | |
102 | 159 | | |
| |||
0 commit comments