Profiling Workers - same timstamp for start and end times


am trying to achieve a very basic profiler by measuring difference in miliseconds in several different code execution points.

    start_time =
     end_time =
    diff_time = end_time - start_time

The values these variables get assigned are as follows:
Start time: 1569593739079 End time: 1569593739079 Diff time: 0 .

I would expect at least the minimall difference - what am I missing here?


I personally return this on the header when debugging.

It was mentioned in a previous discussion by Cloudflare that…
" only advances when I/O is performed, however, and is intentionally coarse."

Which means that you can’t measure how long a worker takes to do some work, but you can measure how long requests using fetch take to complete. If i remember correctly, they also make exact timing harder to avoid timing attacks.