File tree Expand file tree Collapse file tree
opencensus/common/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15+ #include < cstdint>
16+ #include < vector>
17+
1518#include " benchmark/benchmark.h"
1619#include " opencensus/common/internal/random.h"
1720
1821namespace {
1922
2023void BM_GetRandom (benchmark::State& state) {
21- while ( state. KeepRunning () ) {
24+ for ( auto _ : state) {
2225 ::opencensus::common::Random::GetRandom ();
2326 }
2427}
2528BENCHMARK (BM_GetRandom);
2629
2730void BM_Random64 (benchmark::State& state) {
28- while ( state. KeepRunning () ) {
31+ for ( auto _ : state) {
2932 ::opencensus::common::Random::GetRandom ()->GenerateRandom64();
3033 }
3134}
3235BENCHMARK (BM_Random64);
3336
37+ void BM_RandomBuffer (benchmark::State& state) {
38+ const size_t size = state.range (0 );
39+ std::vector<uint8_t > buffer (size);
40+ for (auto _ : state) {
41+ ::opencensus::common::Random::GetRandom ()->GenerateRandomBuffer(
42+ buffer.data(), size);
43+ }
44+ }
45+ BENCHMARK (BM_RandomBuffer)->Range (1 , 16 );
46+
3447} // namespace
3548BENCHMARK_MAIN ();
You can’t perform that action at this time.
0 commit comments