24
24
#include < cstring> // for strcmp
25
25
26
26
#include < QCoreApplication> // for QCoreApplication
27
+ #include < QElapsedTimer> // for QElapsedTimer
27
28
#include < QFile> // for QFile
28
29
#include < QIODevice> // for QIODevice::ReadOnly
29
30
#include < QLocale> // for QLocale
@@ -61,6 +62,8 @@ static constexpr bool DEBUG_LOCALE = false;
61
62
// be careful not to advance argn passed the end of the list, i.e. ensure argn < qargs.size()
62
63
#define FETCH_OPTARG qargs.at(argn).size() > 2 ? QString(qargs.at(argn)).remove(0 ,2 ) : qargs.size()>(argn+1 ) ? qargs.at(++argn) : QString()
63
64
65
+ static QElapsedTimer timer;
66
+
64
67
class QargStackElement
65
68
{
66
69
public:
@@ -247,6 +250,9 @@ class FallbackOutput
247
250
static void
248
251
run_reader (Vecs::fmtinfo_t & ivecs, const QString& fname)
249
252
{
253
+ if (global_opts.debug_level > 0 ) {
254
+ timer.start ();
255
+ }
250
256
start_session (ivecs.fmtname , fname);
251
257
if (ivecs.isDynamic ()) {
252
258
ivecs.fmt = ivecs.factory (fname);
@@ -268,11 +274,18 @@ run_reader(Vecs::fmtinfo_t& ivecs, const QString& fname)
268
274
ivecs->read ();
269
275
ivecs->rd_deinit ();
270
276
}
277
+ if (global_opts.debug_level > 0 ) {
278
+ Warning ().noquote () << QStringLiteral (" %1: reader %2 took %3 seconds." )
279
+ .arg (MYNAME, ivecs.fmtname , QString::number (timer.elapsed ()/1000.0 , ' f' , 3 ));
280
+ }
271
281
}
272
282
273
283
static void
274
284
run_writer (Vecs::fmtinfo_t & ovecs, const QString& ofname)
275
285
{
286
+ if (global_opts.debug_level > 0 ) {
287
+ timer.start ();
288
+ }
276
289
if (ovecs.isDynamic ()) {
277
290
ovecs.fmt = ovecs.factory (ofname);
278
291
Vecs::init_vec (ovecs.fmt );
@@ -293,6 +306,10 @@ run_writer(Vecs::fmtinfo_t& ovecs, const QString& ofname)
293
306
ovecs->write ();
294
307
ovecs->wr_deinit ();
295
308
}
309
+ if (global_opts.debug_level > 0 ) {
310
+ Warning ().noquote () << QStringLiteral (" %1: writer %2 took %3 seconds." )
311
+ .arg (MYNAME, ovecs.fmtname , QString::number (timer.elapsed ()/1000.0 , ' f' , 3 ));
312
+ }
296
313
}
297
314
298
315
static int
@@ -451,6 +468,9 @@ run(const char* prog_name)
451
468
filter = FilterVecs::Instance ().find_filter_vec (argument);
452
469
453
470
if (filter) {
471
+ if (global_opts.debug_level > 0 ) {
472
+ timer.start ();
473
+ }
454
474
if (filter.isDynamic ()) {
455
475
filter.flt = filter.factory ();
456
476
FilterVecs::init_filter_vec (filter.flt );
@@ -471,6 +491,10 @@ run(const char* prog_name)
471
491
filter->deinit ();
472
492
FilterVecs::free_filter_vec (filter.flt );
473
493
}
494
+ if (global_opts.debug_level > 0 ) {
495
+ Warning ().noquote () << QStringLiteral (" %1: filter %2 took %3 seconds." )
496
+ .arg (MYNAME, filter.fltname , QString::number (timer.elapsed ()/1000.0 , ' f' , 3 ));
497
+ }
474
498
} else {
475
499
fatal (" Unknown filter '%s'\n " ,qPrintable (argument));
476
500
}
0 commit comments