diff options
author | Henning Baldersheim <balder@oath.com> | 2018-11-28 18:01:27 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2018-11-28 18:01:27 +0100 |
commit | 02d4f862b3111d9b715bdb4b8ebe536ab5880887 (patch) | |
tree | 8dda0b82268bd4e39e8b58fc8159f92c4fcde402 /vespalib/src/tests/stllike | |
parent | 2dd15d21c181089027240feabe0984e994117402 (diff) |
Randomize keys
Diffstat (limited to 'vespalib/src/tests/stllike')
-rw-r--r-- | vespalib/src/tests/stllike/lookup_benchmark.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/vespalib/src/tests/stllike/lookup_benchmark.cpp b/vespalib/src/tests/stllike/lookup_benchmark.cpp index 1145a110fa2..98aff9cd4ce 100644 --- a/vespalib/src/tests/stllike/lookup_benchmark.cpp +++ b/vespalib/src/tests/stllike/lookup_benchmark.cpp @@ -1,7 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <stddef.h> -#include <stdlib.h> -#include <stdio.h> +#include <cstddef> +#include <cstdlib> +#include <cstdio> #include <map> #include <set> #include <tr1/unordered_set> @@ -20,6 +20,10 @@ void fill(S & s, size_t count) template <typename S> size_t lookup_bench(S & s, size_t count, size_t rep) { + std::vector<uint32_t> keys(count); + for (uint32_t & key : keys) { + key = rand()%count; + } size_t sum(0); typename S::const_iterator e(s.end()); for (size_t j(0); j < rep; j++) { @@ -72,10 +76,10 @@ int main(int argc, char *argv[]) type = argv[1][0]; } if (argc >= 3) { - count = strtoul(argv[2], NULL, 0); + count = strtoul(argv[2], nullptr, 0); } if (argc >= 4) { - rep = strtoul(argv[3], NULL, 0); + rep = strtoul(argv[3], nullptr, 0); } std::vector<const char *> description(256); description['m'] = "std::set"; |