[libc-commits] [libc] [libc] Add --sweep-min-size flag for benchmarks (PR #70302)

Dmitry Vyukov via libc-commits libc-commits at lists.llvm.org
Thu Oct 26 01:29:23 PDT 2023


https://github.com/dvyukov created https://github.com/llvm/llvm-project/pull/70302

We have --sweep-max-size, it's reasonable to have --sweep-min-size as well. It can be used when working on the logic for larger sizes, or to collect a profile for larger sizes only.

>From 9f3ebf3ecf54c7f7603b32e671d21414cc75feeb Mon Sep 17 00:00:00 2001
From: Dmitry Vyukov <dvyukov at google.com>
Date: Tue, 24 Oct 2023 15:27:06 +0200
Subject: [PATCH] [libc] Add --sweep-min-size flag for benchmarks

We have --sweep-max-size, it's reasonable to have --sweep-min-size as well.
It can be used when working on the logic for larger sizes,
or to collect a profile for larger sizes only.
---
 libc/benchmarks/LibcMemoryBenchmarkMain.cpp | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/libc/benchmarks/LibcMemoryBenchmarkMain.cpp b/libc/benchmarks/LibcMemoryBenchmarkMain.cpp
index acd7c30717597a1..bc6fd8b38cb6ddc 100644
--- a/libc/benchmarks/LibcMemoryBenchmarkMain.cpp
+++ b/libc/benchmarks/LibcMemoryBenchmarkMain.cpp
@@ -42,9 +42,15 @@ static cl::opt<std::string>
     SizeDistributionName("size-distribution-name",
                          cl::desc("The name of the distribution to use"));
 
-static cl::opt<bool>
-    SweepMode("sweep-mode",
-              cl::desc("If set, benchmark all sizes from 0 to sweep-max-size"));
+static cl::opt<bool> SweepMode(
+    "sweep-mode",
+    cl::desc(
+        "If set, benchmark all sizes from sweep-min-size to sweep-max-size"));
+
+static cl::opt<uint32_t>
+    SweepMinSize("sweep-min-size",
+                 cl::desc("The minimum size to use in sweep-mode"),
+                 cl::init(0));
 
 static cl::opt<uint32_t>
     SweepMaxSize("sweep-max-size",
@@ -185,7 +191,7 @@ struct MemfunctionBenchmarkSweep final : public MemfunctionBenchmarkBase {
     BO.InitialIterations = 100;
     auto &Measurements = Study.Measurements;
     Measurements.reserve(NumTrials * SweepMaxSize);
-    for (size_t Size = 0; Size <= SweepMaxSize; ++Size) {
+    for (size_t Size = SweepMinSize; Size <= SweepMaxSize; ++Size) {
       CurrentSweepSize = Size;
       runTrials(BO, Measurements);
     }



More information about the libc-commits mailing list