Github user ottobackwards commented on a diff in the pull request: https://github.com/apache/metron/pull/873#discussion_r157377835 --- Diff: metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/shell/StellarExecutor.java --- @@ -289,7 +293,25 @@ public Object execute(String expression) { VariableResolver variableResolver = new MapVariableResolver(Maps.transformValues(variables, result -> result.getResult()) , Collections.emptyMap()); StellarProcessor processor = new StellarProcessor(); - return processor.parse(expression, variableResolver, functionResolver, context); + StackWatch watch = new StackWatch("execute"); + watch.startTime(expression); + context.setWatch(watch); + try { + return processor.parse(expression, variableResolver, functionResolver, context); + } finally { + watch.stopTime(); + final StringBuffer buff = new StringBuffer(); + watch.visit(((level, node) -> { + for (int i = 0; i < level; i++) { + buff.append("-"); + } + buff.append("->"); + buff.append(node.getName()).append(" : ").append(node.getTime()).append("ms : "). + append(node.getNanoTime()).append("ns").append("\n"); + })); + lastTiming = Optional.of(buff.toString()); + context.clearWatch(); + } --- End diff -- I do not have any metrics, but I believe there is low impact to checking the state.context and the thread local's availability. The runtime ( non-shell ) case, we would be paying the penalty of checking that the context watch was there or not, and having it not be there.
---