<html>
<body>
<pre>
<script>
// This script tests the performance of reading cookies. It sets a cookie and
// then reads cookies N times. Finally, it outputs the average time taken to
// read the cookie.
document.cookie =
'one_heck_of_a_crazy_cookie_name=1234567890.1234567890.1234567890.1234567890';
var ok = true;
var num_iters = document.location.search.substring(1) - 0;
if (num_iters == 0)
num_iters = 10000;
document.writeln("num_iters: " + num_iters);
var ts = (new Date()).getTime();
// read the cookie num_iters times
for (var i = 0; i < num_iters; ++i) {
var d = document.cookie;
}
var te = (new Date()).getTime();
var time_per_read = (te - ts) / num_iters;
document.writeln("time per read: " + time_per_read.toFixed(3) + " msec");
</script>
</pre>
</body>
</html>