12 int main(
int argc,
char** argv)
14 const char* benchmark_desc =
"Benchmark tool OpenCog AtomSpace\n"
15 "Usage: atomspace_bm [-m <method>] [options]\n"
16 "-t \tPrint information on type sizes\n"
17 "-A \tBenchmark all methods\n"
18 "-X \tTest the AtomTable API\n"
19 "-g \tTest the Scheme API\n"
20 "-M \tMemoize Scheme expressions\n"
21 "-C \tCompile Scheme expressions\n"
22 "-c \tTest the Python API\n"
23 "-m <methodname>\tMethod to benchmark\n"
24 "-l \tList valid method names to benchmark\n"
25 "-n <int> \tHow many times to call the method in the measurement loop\n"
26 " \t(default: 100000)\n"
27 "-r <int> \tLooping count; how many times a python/scheme operation is looped\n"
29 "-R <int> \tUse specific randomseed; useful for benchmark comparisons\n"
30 " \t(default: time(NULL))\n"
31 "-S <int> \tHow many random atoms to add after each measurement\n"
33 "-- Build test data --\n"
34 "-p <float> \tSet the connection probability or coordination number\n"
36 " \t(-p impact behaviour of -S too)\n"
37 "-s <int> \tSet how many atoms are created (default: 256K)\n"
38 "-d <float> \tChance of using default truth value (default: 0.8)\n"
40 "-k \tCalculate stats (warning, this will affect rss memory reporting)\n"
41 "-f \tSave a csv file with records for every repeated event\n"
42 "-i <int> \tSet interval of data to save\n";
47 fprintf (stderr,
"%s", benchmark_desc);
55 while ((c = getopt (argc, argv,
"tAXgMCcm:ln:r:R:S:p:s:d:kfi:")) != -1) {
72 cerr <<
"Fatal Error: Benchmark not compiled with scheme support!" << endl;
86 cerr <<
"Fatal Error: Benchmark not compiled with cython support!" << endl;
99 benchmarker.
Nreps = (
unsigned int) atoi(optarg);
102 benchmarker.
Nloops = (
unsigned int) atoi(optarg);
105 char* last_arg_char = optarg + strlen(optarg);
106 benchmarker.
randomseed = (
unsigned long) std::strtoul(optarg,
107 &last_arg_char, 10); }
116 benchmarker.
atomCount = (long) atof(optarg);
131 fprintf (stderr,
"%s", benchmark_desc);
134 fprintf (stderr,
"Unknown option %c ", optopt);
148 if (1 != benchmarker.
Nloops)
150 cerr <<
"Fatal Error: the atomspace tests do not support looping\n";
153 if (
true == benchmarker.
memoize)
155 cerr <<
"Fatal Error: memoization not supported for atomspace tests\n";
161 if ((
true == benchmarker.
compile)
164 cerr <<
"Fatal Error: Python does not have a compiler\n";
174 cerr <<
"Fatal Error: Can compile or memoize, but not both!\n";
bool showTypeSizes
number of nodes to build atomspace with before testing
void setMethod(std::string method)
void startBenchmark(int numThreads=1)
int main(int argc, char **argv)