Search code examples
javascriptalgorithmiosdelay

Reference material for calculating response times


I have a mobile application (iOS) that sends instructions via a Comet server (APE) to a web application (JS). For each instruction, the web application responds with an "ack" message, tagged with the instruction id. What I want is to calculate the average response time for the web application.

The frequency of instructions may vary from 5 per second to on every other second (or even longer, depending on the user).

My naive solution is to timestamp each send and receive and then calculate the average among the differences. This is very inefficient since the algorithm (basic for-loop) stalls the application and inflicts a delay in handling the acks. Another solution is to use the ten latest timestamps and thus limiting the number of response times for the calculation.

I'm however not happy with this solution and am looking for some reference material that could provide me any information about the problem that I'm facing.


Solution

  • Here what i use, not based on any scientific material, but works for me...

    We keep the average of the last 10 + we keep the worst 2 ever and the best 2 ever. We don't persist any data, so the worst/best 'ever' are measured since the reboot of the application server.

    Then we make the average over these 14.

    Hope this helps.