From 41e470225aebd2335757a873bd210da159f700db Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Fri, 28 Jul 2023 18:21:56 -0600 Subject: [PATCH] time read, filter and writer operations (#1150) * time read, filter and writer operations when using -D > 0. * take stray dog to the pound. --- main.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/main.cc b/main.cc index 9e90077ab..3c20a5d7b 100644 --- a/main.cc +++ b/main.cc @@ -24,6 +24,7 @@ #include // for strcmp #include // for QCoreApplication +#include // for QElapsedTimer #include // for QFile #include // for QIODevice::ReadOnly #include // for QLocale @@ -61,6 +62,8 @@ static constexpr bool DEBUG_LOCALE = false; // be careful not to advance argn passed the end of the list, i.e. ensure argn < qargs.size() #define FETCH_OPTARG qargs.at(argn).size() > 2 ? QString(qargs.at(argn)).remove(0,2) : qargs.size()>(argn+1) ? qargs.at(++argn) : QString() +static QElapsedTimer timer; + class QargStackElement { public: @@ -247,6 +250,9 @@ class FallbackOutput static void run_reader(Vecs::fmtinfo_t& ivecs, const QString& fname) { + if (global_opts.debug_level > 0) { + timer.start(); + } start_session(ivecs.fmtname, fname); if (ivecs.isDynamic()) { ivecs.fmt = ivecs.factory(fname); @@ -268,11 +274,18 @@ run_reader(Vecs::fmtinfo_t& ivecs, const QString& fname) ivecs->read(); ivecs->rd_deinit(); } + if (global_opts.debug_level > 0) { + Warning().noquote() << QStringLiteral("%1: reader %2 took %3 seconds.") + .arg(MYNAME, ivecs.fmtname, QString::number(timer.elapsed()/1000.0, 'f', 3)); + } } static void run_writer(Vecs::fmtinfo_t& ovecs, const QString& ofname) { + if (global_opts.debug_level > 0) { + timer.start(); + } if (ovecs.isDynamic()) { ovecs.fmt = ovecs.factory(ofname); Vecs::init_vec(ovecs.fmt); @@ -293,6 +306,10 @@ run_writer(Vecs::fmtinfo_t& ovecs, const QString& ofname) ovecs->write(); ovecs->wr_deinit(); } + if (global_opts.debug_level > 0) { + Warning().noquote() << QStringLiteral("%1: writer %2 took %3 seconds.") + .arg(MYNAME, ovecs.fmtname, QString::number(timer.elapsed()/1000.0, 'f', 3)); + } } static int @@ -451,6 +468,9 @@ run(const char* prog_name) filter = FilterVecs::Instance().find_filter_vec(argument); if (filter) { + if (global_opts.debug_level > 0) { + timer.start(); + } if (filter.isDynamic()) { filter.flt = filter.factory(); FilterVecs::init_filter_vec(filter.flt); @@ -471,6 +491,10 @@ run(const char* prog_name) filter->deinit(); FilterVecs::free_filter_vec(filter.flt); } + if (global_opts.debug_level > 0) { + Warning().noquote() << QStringLiteral("%1: filter %2 took %3 seconds.") + .arg(MYNAME, filter.fltname, QString::number(timer.elapsed()/1000.0, 'f', 3)); + } } else { fatal("Unknown filter '%s'\n",qPrintable(argument)); }