Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

306
Views
is ping measured in time to and from the server, or time between the request being made and the server receiving it?

look at the title

idk how to do specifically, a ping in javascript,

but I made this itty bitty snippet that returns

  • the time the request was made,
  • the time the server received the request, (done from server side)
  • and the time the server sent the response.
async function getResponseTimeOnce(){
  var times = {};
  times.beforeRequest = Date.now();
  await fetch("https://randobytes.yimmee.repl.co/ping").then((serverReceive)=>{
    serverReceive.json().then((serverReceive)=>{
      times.serverReceive = serverReceive;
    });
    times.afterRequest = Date.now();
  });
  return times;
}

all I'm asking, is, which values am I supposed to subtract to get the ping time?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

In standard ping programs, the latency measurement is always the round-trip-time (RTT). You should subtract beforeRequest from afterRequest to get the difference.

Source: https://developer.mozilla.org/en-US/docs/Glossary/Round_Trip_Time_(RTT)

$ ping example.com
PING example.com (216.58.194.174): 56 data bytes
64 bytes from 216.58.194.174: icmp_seq=0 ttl=55 time=25.050 ms
64 bytes from 216.58.194.174: icmp_seq=1 ttl=55 time=23.781 ms
64 bytes from 216.58.194.174: icmp_seq=2 ttl=55 time=24.287 ms
64 bytes from 216.58.194.174: icmp_seq=3 ttl=55 time=34.904 ms
64 bytes from 216.58.194.174: icmp_seq=4 ttl=55 time=26.119 ms
--- google.com ping statistics ---
5 packets transmitted, 5 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 23.781/26.828/34.904/4.114 ms

For this particular application, you may also consider using the Performance API to get a high resolution timestamp.

about 4 years ago · Juan Pablo Isaza Report

0

Ping uses RTD/RTT (Round-trip delay/time). The RTD should be calculated from the time you sent the request to the time you receive the response.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!