From 1a3925fc31df0c8810d3a938e750ee2b2bf460df Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Thu, 14 Mar 2024 00:36:35 +0100 Subject: [PATCH] calculate request run time --- index.cgi | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/index.cgi b/index.cgi index 532a323..94c3970 100755 --- a/index.cgi +++ b/index.cgi @@ -1,11 +1,13 @@ #!/bin/sh +read _DATE _date_n <<-EOF + $(date +"%s %N") + EOF + . "${_EXEC:-${0%/*}}/cgilite/cgilite.sh" . "${_EXEC:-${0%/*}}/cgilite/storage.sh" . "${_EXEC:-${0%/*}}/cgilite/json.sh" -[ "$_DATE" ] || _DATE="$(date +%s)" - debug "$REQUEST_METHOD $REQUEST_URI $SERVER_PROTOCOL $_DATE" ingest() { @@ -234,14 +236,14 @@ elif [ "$REQUEST_METHOD" = "POST" ]; then )" results="${results% }" - times >&2 + t="$(( ${_DATE}${_date_n} - $(date +%s%N) ))" cat <<-EOF Status: 200 OK X-elastic-product: Elasticsearch Content-Type: application/vnd.elasticsearch+json;compatible-with=8 - { "took":0, + { "took":$((t / 1000)), "timed_out":false, "hits": { "total":{"value": $(DB2 "$results" count @) ,"relation":"eq"}, -- 2.39.2