summaryrefslogtreecommitdiffstats
path: root/chrome/test/data/read_cookies.html
blob: b457c34e8ba923ba31bf93c8c2cf5ee05228b8ed (plain)
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
29
30
31
32
33
34
35
<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>