Prepare to following patches, still no functional
change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
#include "benchmark.h"
#include "search.h"
#include "benchmark.h"
#include "search.h"
/// transposition table size and the number of search threads that should
/// be used. The analysis is written to a file named bench.txt.
/// transposition table size and the number of search threads that should
/// 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;
Move moves[1] = {MOVE_NONE};
Position pos;
Move moves[1] = {MOVE_NONE};
- int i;
-
- i = atoi(ttSize.c_str());
- if(i < 4 || i > 1024) {
- std::cerr << "The hash table size must be between 4 and 1024" << std::endl;
- exit(EXIT_FAILURE);
- }
+ std::string ttSize, threads, fileName;
+ std::istringstream csVal(commandLine);
+ std::istringstream csStr(commandLine);
+ int val, time;
- i = atoi(threads.c_str());
- if(i < 1 || i > THREAD_MAX) {
- std::cerr << "The number of threads must be between 1 and " << THREAD_MAX
- << std::endl;
- exit(EXIT_FAILURE);
+ csStr >> ttSize;
+ csVal >> val;
+ if (val < 4 || val > 1024)
+ {
+ std::cerr << "The hash table size must be between 4 and 1024" << std::endl;
+ exit(EXIT_FAILURE);
+ csStr >> threads;
+ csVal >> val;
+ if (val < 1 || val > THREAD_MAX)
+ {
+ std::cerr << "The number of threads must be between 1 and " << THREAD_MAX
+ << std::endl;
+ exit(EXIT_FAILURE);
+ }
set_option_value("Hash", ttSize);
set_option_value("Threads", threads);
set_option_value("OwnBook", "false");
set_option_value("Use Search Log", "true");
set_option_value("Search Log Filename", "bench.txt");
set_option_value("Hash", ttSize);
set_option_value("Threads", threads);
set_option_value("OwnBook", "false");
set_option_value("Use Search Log", "true");
set_option_value("Search Log Filename", "bench.txt");
- for(i = 0; i < 15; i++) {
- pos.from_fen(BenchmarkPositions[i]);
- think(pos, true, false, 0, 0, 0, 0, 0, 60000, moves);
+ csVal >> time; // In seconds
+ csVal >> fileName;
+
+ 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);
-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)
#include "uci.h"
#include "ucioption.h"
#include "uci.h"
#include "ucioption.h"
init_threads();
// Make random number generation less deterministic, for book moves
init_threads();
// Make random number generation less deterministic, for book moves
- int i = abs(get_system_time() % 10000);
- for(int j = 0; j < i; j++)
- genrand_int32();
+ for (int i = abs(get_system_time() % 10000); i > 0; i--)
+ genrand_int32();
// Process command line arguments
// Process command line arguments
- if(argc >= 2) {
- if(std::string(argv[1]) == "bench") {
- if(argc != 4) {
- std::cout << "Usage: glaurung bench <hash> <threads>" << std::endl;
+ if (argc >= 2 && string(argv[1]) == "bench")
+ {
+ if (argc < 4 || argc > 6)
+ {
+ std::cout << "Usage: glaurung bench <hash size> <threads> "
+ << "[time = 60s] [fen positions file = default]"
+ << std::endl;
- 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);
}
// Print copyright notice
}
// Print copyright notice