cmcfarlen commented on code in PR #12616: URL: https://github.com/apache/trafficserver/pull/12616#discussion_r2466163460
########## 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: Oh, that's a good idea. I can add that from the std side easily. From what I understand, the random engines are uniform integer generators, but they can have bias around some ranges. I wanted to measure that bias to see if we actually care about that enough to accept the overhead the uniform distribution has. I don't think we do, but I'm still investigating. -- 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]
