更新时间:2021-09-20 08:39:06
大多数小应用程序的技术,包括JavaScript,强制执行同源策略。有可能动态地添加DOM元素,例如图像,并收集用onload事件处理程序的定时信息。
Most applet technology, including Javascript, enforces a same-origin policy. It may be possible to dynamically add DOM elements, such as images, and collect timing information using the onload event handler.
Psuedo- code
Psuedo-code
for (server in servers) {
var img = document.createElement('IMG');
server.startTime = getCurrentTimeInMS();
img.onload=function() { server.endTime = getcurrentTimeInMS(); }
img.src = server.imgUrl;
}
然后等待一个合适的时间和检查的时间为每个服务器对象。根据需要和计算平均数,如果你想重复。我不知道你能期待什么样的精度。
Then wait an appropriate time and check the timing for each server object. Repeat as needed and compute averages if you want. I'm not sure what kind of accuracy you can expect.
缺点: