From b84032466e31ff23d4be3b81a3f535b2c70202e5 Mon Sep 17 00:00:00 2001 From: Alexei Sheplyakov Date: Sun, 14 Sep 2008 06:57:21 +0400 Subject: [PATCH] check: time_parser.cpp: don't run the same benchmark twice. Since ex(const string&, lst&) ctor uses the new parser now comparing its performance (and result) with one of direct invocation of the parser is pointless. --- check/time_parser.cpp | 39 +++++++++------------------------------ 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/check/time_parser.cpp b/check/time_parser.cpp index 27316364..4e6081b1 100644 --- a/check/time_parser.cpp +++ b/check/time_parser.cpp @@ -21,33 +21,14 @@ static string prepare_str(const unsigned n, const char x = 'x') return s.str(); } -void benchmark_and_cmp(const string& srep, double& t_new, double& t_old) +static double benchmark_and_cmp(const string& srep) { parser the_parser; timer RSD10; RSD10.start(); ex e = the_parser(srep); - t_new = RSD10.read(); - RSD10.stop(); - if (t_new > 2.0) - cout << '.' << flush; - - symtab syms = the_parser.get_syms(); - const symbol x = find_or_insert_symbol("x", syms, true); - lst sl; - sl = x; - RSD10.start(); - ex e2(srep, sl); - t_old = RSD10.read(); - - if (t_old > 2.0) - cout << '.' << flush; - - ex dif = (e - e2).expand(); - if (!dif.is_zero()) { - cerr << "Got a difference: " << dif << endl; - throw std::logic_error("New and old parser give different results"); - } + const double t = RSD10.read(); + return t; } int main(int argc, char** argv) @@ -59,20 +40,18 @@ int main(int argc, char** argv) if (argc > 1) n_max = atoi(argv[1]); - vector times_new, times_old; + vector times; vector ns; for (unsigned n = n_min; n <= n_max; n = n << 1) { - double t_new, t_old; string srep = prepare_str(n); - benchmark_and_cmp(srep, t_new, t_old); - times_new.push_back(t_new); - times_old.push_back(t_old); + const double t = benchmark_and_cmp(srep); + times.push_back(t); ns.push_back(n); } cout << "OK" << endl; - cout << "# terms new parser, s old parser, s" << endl; - for (size_t i = 0; i < times_new.size(); i++) - cout << " " << ns[i] << '\t' << times_new[i] << '\t' << times_old[i] << endl; + cout << "# terms time, s" << endl; + for (size_t i = 0; i < times.size(); i++) + cout << " " << ns[i] << '\t' << times[i] << endl; return 0; } -- 2.45.0