Is there a way to get /tool/fetch response time?

I would like to know how long it takes to fetch a URL. Is there a way to do so within a script?

unless you do it at the turn of midnight, if you memorize the time before the download and compare it with the time after the download…

How about using :timestamp? While Mikrotik doesn’t support dates or floats, they do have “time” and “time difference” type… Super useful here.

{ 
  :local start [:timestamp]
  /tool/fetch url="https://wttr.in/Riga+LV?T&format=2" output=user
  :local stop [:timestamp]
  :put ($stop-$start)
}

Which takes 3.1 seconds (or “00:00:03.103317400”), and we knows it’s -2C & breezy in Riga, Latvia.

  status: finished
  downloaded: 0K
        data:               -2  C           20km/h


00:00:03.103317400

Note: In theory, you might not want to use “output=user”, and use “output=none” to time it. The output to display a relatively large amount of some time. In fact almost 2 second to write to terminal. And if you normally write to disk, timing it it that way be most accurate (output=file).

 { :local start [:timestamp]; /tool/fetch url="https://wttr.in/Riga+LV?T&format=2" output=none; :local stop [:timestamp]; :put ($stop-$start)}

      status: finished
  downloaded: 0KiBC-z pause]
       total: 0KiB
    duration: 0s

00:00:01.099018660