X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=check%2Ftime_parser.cpp;h=4e6081b194f923f2e87c57184e40f158344151dc;hp=ca35fb629fcb7ee98e4ec81ddef770b30cd84fe5;hb=40d2f5d1ddacf71991adb447b163a19136ee2179;hpb=1222eac51cee964961d2aad889dc4ceccb144a36 diff --git a/check/time_parser.cpp b/check/time_parser.cpp index ca35fb62..4e6081b1 100644 --- a/check/time_parser.cpp +++ b/check/time_parser.cpp @@ -6,7 +6,6 @@ #include #include #include "ginac.h" -#include "parser/parser.hpp" #include "timer.h" extern void randomify_symbol_serials(); using namespace std; @@ -22,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) @@ -60,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; }