Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

313
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda