diff --git a/README.md b/README.md index 8d104bb..00e70c8 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ All requests require these two fields to be specified: All responses will include these fields: - `id` (string): corresponding to the request ID - `success` (boolean): whether or not the request was successful +- `execution_time` (long): elapsed time in millis If an error occurs, all responses will include these fields: - `error`: a description of the error diff --git a/src/main/java/com/github/ibm/mapepire/ClientRequest.java b/src/main/java/com/github/ibm/mapepire/ClientRequest.java index e05abb9..31399cd 100644 --- a/src/main/java/com/github/ibm/mapepire/ClientRequest.java +++ b/src/main/java/com/github/ibm/mapepire/ClientRequest.java @@ -5,6 +5,7 @@ import java.sql.SQLException; import java.util.LinkedHashMap; import java.util.Map; +import java.util.concurrent.TimeUnit; import com.github.theprez.jcmdutils.StringUtils; import com.google.gson.Gson; @@ -81,6 +82,7 @@ protected void processAfterReplySent() { @Override public void run() { + long startTime = System.nanoTime(); try { go(); addReplyData("success", true); @@ -95,6 +97,7 @@ public void run() { } } finally { try { + addReplyData("execution_time", TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime)); sendreply(); processAfterReplySent(); } catch (final Exception e) {