Skip to content

Commit e3d391c

Browse files
committed
Slow random number generation is totally unwarranted.
1 parent 60a7c50 commit e3d391c

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

benchmarks/bulk-insert-and-query.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,6 @@ Statistics FilterBenchmark(
454454
result.add_count = add_count;
455455
result.nanos_per_add = static_cast<double>(time) / add_count;
456456
result.bits_per_item = static_cast<double>(CHAR_BIT * filter.SizeInBytes()) / add_count;
457-
::std::random_device random;
458457
size_t found_count = 0;
459458
#ifdef __linux__
460459
vector<int> evts;
@@ -591,10 +590,10 @@ int main(int argc, char * argv[]) {
591590
}
592591
}
593592
vector<uint64_t> to_add = seed == -1 ?
594-
GenerateRandom64<::std::random_device>(add_count) :
593+
GenerateRandom64Fast(add_count, rand()) :
595594
GenerateRandom64Fast(add_count, seed);
596595
vector<uint64_t> to_lookup = seed == -1 ?
597-
GenerateRandom64<::std::random_device>(SAMPLE_SIZE) :
596+
GenerateRandom64Fast(SAMPLE_SIZE, rand()) :
598597
GenerateRandom64Fast(SAMPLE_SIZE, seed + add_count);
599598
if (seed >= 0 && seed < 64) {
600599
// 0-64 are special seeds
@@ -623,7 +622,6 @@ int main(int argc, char * argv[]) {
623622
constexpr int NAME_WIDTH = 32;
624623

625624
cout << StatisticsTableHeader(NAME_WIDTH, 5) << endl;
626-
627625
if (algorithmId == 0 || algorithmId < 0) {
628626
auto cf = FilterBenchmark<
629627
XorFilter<uint64_t, uint8_t, SimpleMixSplit>>(

benchmarks/random.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <stdexcept>
1010
#include <vector>
1111

12+
// this can be atrociously slow
1213
template <class RNG = ::std::random_device>
1314
::std::vector<::std::uint64_t> GenerateRandom64(::std::size_t count) {
1415
::std::vector<::std::uint64_t> result(count);

0 commit comments

Comments
 (0)