summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Seigo <aseigo@kde.org>2015-12-25 10:31:24 +0100
committerAaron Seigo <aseigo@kde.org>2015-12-25 10:31:24 +0100
commitad442fb49e5d4271a5f2276eb73d9d15b1e8755f (patch)
tree46e469ae1c3524b0369339e5962b434fa9a707a5
parentf52da78a2da39974f27faf34915adc6dcb80b4c8 (diff)
downloadsink-ad442fb49e5d4271a5f2276eb73d9d15b1e8755f.tar.gz
sink-ad442fb49e5d4271a5f2276eb73d9d15b1e8755f.zip
support command timing output
-rw-r--r--akonadish/syntaxtree.cpp13
-rw-r--r--akonadish/syntaxtree.h2
2 files changed, 10 insertions, 5 deletions
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
62 62
63bool SyntaxTree::run(const QStringList &commands) 63bool SyntaxTree::run(const QStringList &commands)
64{ 64{
65 bool success = false;
66 m_timeElapsed.start();
65 Command command = match(commands); 67 Command command = match(commands);
66 if (command.first && command.first->lambda) { 68 if (command.first && command.first->lambda) {
67 bool rv = command.first->lambda(command.second, m_state); 69 success = command.first->lambda(command.second, m_state);
68 if (rv && command.first->interactivity == Syntax::EventDriven) { 70 if (success && command.first->interactivity == Syntax::EventDriven) {
69 return m_state.commandStarted(); 71 success = m_state.commandStarted();
70 } 72 }
71
72 return rv;
73 } 73 }
74 74
75 if (m_state.commandTiming()) {
76 m_state.printLine(QObject::tr("Time elapsed: %1").arg(m_timeElapsed.elapsed()));
77 }
75 return false; 78 return false;
76} 79}
77 80
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 @@
22#include "state.h" 22#include "state.h"
23 23
24#include <QStringList> 24#include <QStringList>
25#include <QTime>
25#include <QVector> 26#include <QVector>
26 27
27class Syntax 28class Syntax
@@ -70,6 +71,7 @@ private:
70 71
71 Syntax::List m_syntax; 72 Syntax::List m_syntax;
72 State m_state; 73 State m_state;
74 QTime m_timeElapsed;
73 static SyntaxTree *s_module; 75 static SyntaxTree *s_module;
74}; 76};
75 77