10 extern void randomify_symbol_serials();
12 using namespace GiNaC;
14 /// make a string "1+x+2*x^2+...+n*x^n"
15 static string prepare_str(const unsigned n, const char x = 'x')
19 for (unsigned i = 2; i < n; i++)
20 s << '+' << i << '*' << x << '^' << i;
24 static double benchmark_and_cmp(const string& srep)
29 ex e = the_parser(srep);
30 const double t = RSD10.read();
34 int main(int argc, char** argv)
36 cout << "timing GiNaC parser..." << flush;
37 randomify_symbol_serials();
38 unsigned n_min = 1024;
39 unsigned n_max = 32768;
41 n_max = atoi(argv[1]);
45 for (unsigned n = n_min; n <= n_max; n = n << 1) {
46 string srep = prepare_str(n);
47 const double t = benchmark_and_cmp(srep);
53 cout << "# terms time, s" << endl;
54 for (size_t i = 0; i < times.size(); i++)
55 cout << " " << ns[i] << '\t' << times[i] << endl;