JosiahWI commented on code in PR #12616: URL: https://github.com/apache/trafficserver/pull/12616#discussion_r2466141339
########## tools/benchmark/benchmark_Random.cc: ########## @@ -0,0 +1,126 @@ + +/** @file + +Simple benchmark for ProxyAllocator + +@section license License + +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include "tscore/ink_rand.h" +#include <cmath> +#include <limits> +#define CATCH_CONFIG_ENABLE_BENCHMARKING +#include <catch2/catch_test_macros.hpp> +#include <catch2/benchmark/catch_benchmark.hpp> +#include <catch2/generators/catch_generators_random.hpp> + +#include "tscore/Random.h" + +TEST_CASE("BenchRandom", "[bench][random]") +{ + InkRand gen(42); + ts::Random::seed(13); + int iterations = 1000000; + + BENCHMARK("IncRand") + { + uint64_t sum = 0; + for (int i = 0; i < iterations; i++) { + sum += gen.random(); + } + return sum; + }; Review Comment: Catch2 will already perform multiple iterations of the benchmark. What is the reason for performing a fixed number of iterations in the benchmarked routine? Does Catch2 underestimate the number of runs to perform? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
