Skip to content

Commit d97cbc1

Browse files
authored
Use bench for a short benchmark and benchmark for a full one. (#2120)
1 parent 64d3951 commit d97cbc1

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

src/main.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ int main(int argc, const char** argv) {
5656
CommandLine::RegisterMode("uci", "(default) Act as UCI engine");
5757
CommandLine::RegisterMode("selfplay", "Play games with itself");
5858
CommandLine::RegisterMode("benchmark", "Quick benchmark");
59+
CommandLine::RegisterMode("bench", "Very quick benchmark");
5960
CommandLine::RegisterMode("backendbench",
6061
"Quick benchmark of backend only");
6162
CommandLine::RegisterMode("leela2onnx", "Convert Leela network to ONNX.");
@@ -75,11 +76,14 @@ int main(int argc, const char** argv) {
7576
// Selfplay mode.
7677
SelfPlayLoop loop;
7778
loop.RunLoop();
78-
} else if (CommandLine::ConsumeCommand("benchmark") ||
79-
CommandLine::ConsumeCommand("bench")) {
80-
// Benchmark mode.
79+
} else if (CommandLine::ConsumeCommand("benchmark")) {
80+
// Benchmark mode, longer version.
8181
Benchmark benchmark;
8282
benchmark.Run();
83+
} else if (CommandLine::ConsumeCommand("bench")) {
84+
// Benchmark mode, shorter version.
85+
Benchmark benchmark;
86+
benchmark.Run(/*run_shorter_benchmark=*/true);
8387
} else if (CommandLine::ConsumeCommand("backendbench")) {
8488
// Backend Benchmark mode.
8589
BackendBenchmark benchmark;

src/tools/benchmark.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const OptionId kNumPositionsId{"num-positions", "",
4848
"The number of benchmark positions to test."};
4949
} // namespace
5050

51-
void Benchmark::Run() {
51+
void Benchmark::Run(bool run_shorter_benchmark) {
5252
OptionsParser options;
5353
SharedBackendParams::Populate(&options);
5454
options.Add<IntOption>(kThreadsOptionId, 1, 128) = kDefaultThreads;
@@ -57,9 +57,14 @@ void Benchmark::Run() {
5757
classic::SearchParams::Populate(&options);
5858

5959
options.Add<IntOption>(kNodesId, -1, 999999999) = -1;
60-
options.Add<IntOption>(kMovetimeId, -1, 999999999) = 500;
6160
options.Add<StringOption>(kFenId) = "";
62-
options.Add<IntOption>(kNumPositionsId, 1, 34) = 10;
61+
if (run_shorter_benchmark) {
62+
options.Add<IntOption>(kMovetimeId, -1, 999999999) = 500;
63+
options.Add<IntOption>(kNumPositionsId, 1, 34) = 10;
64+
} else {
65+
options.Add<IntOption>(kMovetimeId, -1, 999999999) = 10000;
66+
options.Add<IntOption>(kNumPositionsId, 1, 34) = 34;
67+
}
6368

6469
if (!options.ProcessAllFlags()) return;
6570

src/tools/benchmark.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class Benchmark{
7878
"3Qb1k1/1r2ppb1/pN1n2q1/Pp1Pp1Pr/4P2p/4BP2/4B1R1/1R5K b - - 11 40"
7979
};
8080

81-
void Run();
81+
void Run(bool run_shorter_benchmark = false);
8282
void OnBestMove(const BestMoveInfo& move);
8383
void OnInfo(const std::vector<ThinkingInfo>& infos);
8484
};

0 commit comments

Comments
 (0)