]> www.ginac.de Git - ginac.git/commitdiff
check: time_parser.cpp: don't run the same benchmark twice.
authorAlexei Sheplyakov <varg@theor.jinr.ru>
Sun, 14 Sep 2008 02:57:21 +0000 (06:57 +0400)
committerAlexei Sheplyakov <varg@theor.jinr.ru>
Fri, 19 Sep 2008 09:15:50 +0000 (13:15 +0400)
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

index 273163648c6c30be360329778f5e5d1413e132d5..4e6081b194f923f2e87c57184e40f158344151dc 100644 (file)
@@ -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<double> times_new, times_old;
+       vector<double> times;
        vector<unsigned> 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;
 }