JSFiddle - React, Tailwind, and code Playground
by russau
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/async/1.4.0/async.min.js"></script>
JavaScript
var count = 0;
async.whilst(
function () {
return count < 10;
},
function (callback) {
count++;
var original = new Date().getTime() ;
// original - t0 - localtime that we sent the message
// returned - t3 - localtime that we got a response
// receive - t1 server time that we recieved the message
// transmit - t2 server time that we returned
// sending = t1 - t0 local original - server receive
// receiving = t3 - t2 server transmit - local arrival
// roundtrip = front delta + back delta
// oneway = split the difference
// difference =
$.ajax({
type: "GET",
url: "https://zmm7pnokp4.execute-api.us-east-1.amazonaws.com/prod",
success: function (output, status, xhr) {
var returned = (new Date).getTime();
var receive = +output; // lambda is giving the same values here
var transmit = +output;
var sending = receive - original;
var receiving = transmit - returned;
var roundtrip = sending + receiving;
var skew = roundtrip / 2;
$('body').append("sending: " + sending);
$('body').append(" receiving: " + receiving);
$('body').append(" roundtrip: " + roundtrip);
$('body').append(" skew: " + skew);
$('body').append('<br/>');
setTimeout(callback, 1000);
},
error: function (output) {}
});
},
function (err) {});