mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
Reformat benchmark interface
Prepare to following patches, still no functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
2f5012a3eb
commit
f1e245850f
3 changed files with 45 additions and 29 deletions
|
@ -20,6 +20,7 @@
|
||||||
////
|
////
|
||||||
//// Includes
|
//// Includes
|
||||||
////
|
////
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
#include "benchmark.h"
|
#include "benchmark.h"
|
||||||
#include "search.h"
|
#include "search.h"
|
||||||
|
@ -59,33 +60,45 @@ const std::string BenchmarkPositions[15] = {
|
||||||
/// transposition table size and the number of search threads that should
|
/// transposition table size and the number of search threads that should
|
||||||
/// be used. The analysis is written to a file named bench.txt.
|
/// be used. The analysis is written to a file named bench.txt.
|
||||||
|
|
||||||
void benchmark(const std::string &ttSize, const std::string &threads) {
|
void benchmark(const std::string& commandLine) {
|
||||||
|
|
||||||
Position pos;
|
Position pos;
|
||||||
Move moves[1] = {MOVE_NONE};
|
Move moves[1] = {MOVE_NONE};
|
||||||
int i;
|
std::string ttSize, threads, fileName;
|
||||||
|
std::istringstream csVal(commandLine);
|
||||||
|
std::istringstream csStr(commandLine);
|
||||||
|
int val, time;
|
||||||
|
|
||||||
i = atoi(ttSize.c_str());
|
csStr >> ttSize;
|
||||||
if(i < 4 || i > 1024) {
|
csVal >> val;
|
||||||
std::cerr << "The hash table size must be between 4 and 1024" << std::endl;
|
if (val < 4 || val > 1024)
|
||||||
exit(EXIT_FAILURE);
|
{
|
||||||
|
std::cerr << "The hash table size must be between 4 and 1024" << std::endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
csStr >> threads;
|
||||||
i = atoi(threads.c_str());
|
csVal >> val;
|
||||||
if(i < 1 || i > THREAD_MAX) {
|
if (val < 1 || val > THREAD_MAX)
|
||||||
std::cerr << "The number of threads must be between 1 and " << THREAD_MAX
|
{
|
||||||
<< std::endl;
|
std::cerr << "The number of threads must be between 1 and " << THREAD_MAX
|
||||||
exit(EXIT_FAILURE);
|
<< std::endl;
|
||||||
}
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
set_option_value("Hash", ttSize);
|
set_option_value("Hash", ttSize);
|
||||||
set_option_value("Threads", threads);
|
set_option_value("Threads", threads);
|
||||||
set_option_value("OwnBook", "false");
|
set_option_value("OwnBook", "false");
|
||||||
set_option_value("Use Search Log", "true");
|
set_option_value("Use Search Log", "true");
|
||||||
set_option_value("Search Log Filename", "bench.txt");
|
set_option_value("Search Log Filename", "bench.txt");
|
||||||
|
|
||||||
for(i = 0; i < 15; i++) {
|
csVal >> time; // In seconds
|
||||||
pos.from_fen(BenchmarkPositions[i]);
|
csVal >> fileName;
|
||||||
think(pos, true, false, 0, 0, 0, 0, 0, 60000, moves);
|
|
||||||
|
if (fileName != "default")
|
||||||
|
exit(0);
|
||||||
|
|
||||||
|
for (int i = 0; i < 15; i++)
|
||||||
|
{
|
||||||
|
pos.from_fen(BenchmarkPositions[i]);
|
||||||
|
think(pos, true, false, 0, 0, 0, 0, 0, time * 1000, moves);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
//// Prototypes
|
//// Prototypes
|
||||||
////
|
////
|
||||||
|
|
||||||
extern void benchmark(const std::string &ttSize, const std::string &threads);
|
extern void benchmark(const std::string& commandLine);
|
||||||
|
|
||||||
|
|
||||||
#endif // !defined(BENCHMARK_H_INCLUDED)
|
#endif // !defined(BENCHMARK_H_INCLUDED)
|
||||||
|
|
22
src/main.cpp
22
src/main.cpp
|
@ -39,6 +39,7 @@
|
||||||
#include "uci.h"
|
#include "uci.h"
|
||||||
#include "ucioption.h"
|
#include "ucioption.h"
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
////
|
////
|
||||||
//// Functions
|
//// Functions
|
||||||
|
@ -67,20 +68,23 @@ int main(int argc, char *argv[]) {
|
||||||
init_threads();
|
init_threads();
|
||||||
|
|
||||||
// Make random number generation less deterministic, for book moves
|
// Make random number generation less deterministic, for book moves
|
||||||
int i = abs(get_system_time() % 10000);
|
for (int i = abs(get_system_time() % 10000); i > 0; i--)
|
||||||
for(int j = 0; j < i; j++)
|
genrand_int32();
|
||||||
genrand_int32();
|
|
||||||
|
|
||||||
// Process command line arguments
|
// Process command line arguments
|
||||||
if(argc >= 2) {
|
if (argc >= 2 && string(argv[1]) == "bench")
|
||||||
if(std::string(argv[1]) == "bench") {
|
{
|
||||||
if(argc != 4) {
|
if (argc < 4 || argc > 6)
|
||||||
std::cout << "Usage: glaurung bench <hash> <threads>" << std::endl;
|
{
|
||||||
|
std::cout << "Usage: glaurung bench <hash size> <threads> "
|
||||||
|
<< "[time = 60s] [fen positions file = default]"
|
||||||
|
<< std::endl;
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
benchmark(std::string(argv[2]), std::string(argv[3]));
|
string time = argc > 4 ? argv[4] : "60";
|
||||||
|
string fen = argc > 5 ? argv[5] : "default";
|
||||||
|
benchmark(string(argv[2]) + " " + string(argv[3]) + " " + time + " " + fen);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print copyright notice
|
// Print copyright notice
|
||||||
|
|
Loading…
Add table
Reference in a new issue