forked from WebKit/WebKit-http
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcookieSpeedTest.html
28 lines (27 loc) · 940 Bytes
/
cookieSpeedTest.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<html><head><title>Cookie Test</title>
<script>
function cookieTest(){
var totalW = 0.0;
var totalR = 0.0;
var numLoops = 100;
for(var i=0; i < numLoops; i++){
var randomNumber=Math.floor(Math.random()*11);
var time = new Date();
time.setTime(time.getTime() + 1000);
var cookieString = "cookie" + randomNumber + "=true; expires=" + time.toGMTString();
var preW = new Date().getTime();
document.cookie = cookieString;
var postW = new Date().getTime();
if(document.cookie.indexOf(("cookie" + randomNumber)> 0));
var postR = new Date().getTime();
totalW += (postW - preW);
totalR += (postR - postW);
}
document.write("<br><br>avg R(millis):" + totalR/numLoops);
document.write("<br>avg W(millis):" + totalW/numLoops);
}
</script>
</head>
<body onload="javascript:cookieTest();setTimeout(cookieTest(), 1000);">
</body>
</html>