I was trying to figure out a way to find out how much time the CURL command given below is taking.
curl -XGET --header 'Content-Type: application/json' http://localhost:9200/elastiknn100knew11/_search -d '{"query": {
   "elastiknn_nearest_neighbors": {  
            "field": "my-vec", 
            "vec": {   
              "values":[Array of Numbers]
            },
            "model": "lsh",                       
            "similarity": "l2",
            "candidates": 50
        }
  },
"fields": ["imageName"],
"_source": false
}'
So, I came up with a bash script.
#!/bin/bash
start=$(( $(gdate +%N) ))
echo $start
curl -XGET --header 'Content-Type: application/json' http://localhost:9200/elastiknn100knew11/_search -d '{"query": {
   "elastiknn_nearest_neighbors": {  
            "field": "my-vec", 
            "vec": {   
              "values":[Array of Numbers]
            },
            "model": "lsh",                       
            "similarity": "l2",
            "candidates": 50
        }
  },
"fields": ["imageName"],
"_source": false
}'
dur=$(( $(gdate +%N) -$start))
echo $dur
By this although i got the difference in nanoseconds, but there could be a possibility that I run my command at 12:59:59:9DigitNanoSeconds and the query gets executed by 1:00:00:9DigitNanoSeconds then our output would come to be in negative.
I tried this situation out and got the time as negative in this scenario. So, is there any other alternative for this or maybe something we could do for this scenario?