- setbuf(stdin, NULL);
- setbuf(stdout, NULL);
- std::cout.rdbuf()->pubsetbuf(NULL, 0);
- std::cin.rdbuf()->pubsetbuf(NULL, 0);
-
- // Initialization
-
- init_mersenne();
- init_direction_table();
- init_bitboards();
- init_uci_options();
- Position::init_zobrist();
- Position::init_piece_square_tables();
- MaterialInfo::init();
- MovePicker::init_phase_table();
- init_eval(1);
- init_bitbases();
- 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();
-
- // 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;
- exit(0);
+ cout.rdbuf()->pubsetbuf(NULL, 0);
+ cin.rdbuf()->pubsetbuf(NULL, 0);
+
+ // Initialization through global resources manager
+ Application::initialize();
+
+#ifdef USE_CALLGRIND
+ CALLGRIND_START_INSTRUMENTATION;
+#endif
+
+ // Process command line arguments if any
+ if (argc > 1)
+ {
+ if (string(argv[1]) != "bench" || argc < 4 || argc > 8)
+ cout << "Usage: stockfish bench <hash size> <threads> "
+ << "[time = 60s] [fen positions file = default] "
+ << "[time, depth or node limited = time] "
+ << "[timing file name = none]" << endl;
+ else
+ {
+ string time = argc > 4 ? argv[4] : "60";
+ string fen = argc > 5 ? argv[5] : "default";
+ string lim = argc > 6 ? argv[6] : "time";
+ string tim = argc > 7 ? argv[7] : "";
+ benchmark(string(argv[2]) + " " + string(argv[3]) + " " + time + " " + fen + " " + lim + " " + tim);