From ad442fb49e5d4271a5f2276eb73d9d15b1e8755f Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Fri, 25 Dec 2015 10:31:24 +0100 Subject: support command timing output --- akonadish/syntaxtree.cpp | 13 ++++++++----- akonadish/syntaxtree.h | 2 ++ 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'akonadish') diff --git a/akonadish/syntaxtree.cpp b/akonadish/syntaxtree.cpp index 899fc61..dbbff01 100644 --- a/akonadish/syntaxtree.cpp +++ b/akonadish/syntaxtree.cpp @@ -62,16 +62,19 @@ Syntax::List SyntaxTree::syntax() const bool SyntaxTree::run(const QStringList &commands) { + bool success = false; + m_timeElapsed.start(); Command command = match(commands); if (command.first && command.first->lambda) { - bool rv = command.first->lambda(command.second, m_state); - if (rv && command.first->interactivity == Syntax::EventDriven) { - return m_state.commandStarted(); + success = command.first->lambda(command.second, m_state); + if (success && command.first->interactivity == Syntax::EventDriven) { + success = m_state.commandStarted(); } - - return rv; } + if (m_state.commandTiming()) { + m_state.printLine(QObject::tr("Time elapsed: %1").arg(m_timeElapsed.elapsed())); + } return false; } diff --git a/akonadish/syntaxtree.h b/akonadish/syntaxtree.h index 3421fc3..5ee915a 100644 --- a/akonadish/syntaxtree.h +++ b/akonadish/syntaxtree.h @@ -22,6 +22,7 @@ #include "state.h" #include +#include #include class Syntax @@ -70,6 +71,7 @@ private: Syntax::List m_syntax; State m_state; + QTime m_timeElapsed; static SyntaxTree *s_module; }; -- cgit v1.2.3