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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
<!doctype html>
<html>
<head>
<style>
pre { padding: 5px; border: 1px solid black; }
</style>
<script>
var db;
try {
if (window.openDatabase) {
db = openDatabase("StressTest1", "1.0", "Database Stress Test", 200000);
if (!db)
alert("Failed to open the database on disk. This is probably because the version was bad or there is not enough space left in this domain's quota");
} else
alert("Couldn't open the database.");
} catch(err) { }
var highestId = 0;
var allData = new Array();
function newData()
{
var id = ++highestId;
allData.push(id);
db.transaction(function (tx)
{
tx.executeSql("INSERT INTO FillerData (id, filler) VALUES (?, randomblob(1024))", [id]);
});
}
function testOpen()
{
for (var i = 0; i < 4; i++) {
newData();
}
setTimeout("testClose();", 0);
}
function testClose()
{
db.transaction(function(tx)
{
for (var i = 0; i < allData.length; i++)
tx.executeSql("DELETE FROM FillerData WHERE id = ?", [allData[i]]);
allData = new Array();
});
setTimeout("testOpen();", 0);
}
function updateTransactionCount()
{
document.getElementById("transactionCount").innerHTML = "Current Transaction Count: " + highestId;
setTimeout("updateTransactionCount();", 1000);
}
function loaded()
{
db.transaction(function(tx) {
tx.executeSql("SELECT COUNT(*) FROM FillerData", [], function(result) { }, function(tx, error) {
tx.executeSql("CREATE TABLE FillerData (id REAL UNIQUE, filler)", [], function(result) {
});
});
});
setTimeout("testOpen();", 0);
setTimeout("updateTransactionCount();", 1000);
}
addEventListener('load', loaded, false);
</script>
</head>
<body>
This test stresses the database threading code by constantly opening transactions to the test database at a fast rate.<br>
See radar 5729446 for more details.<br>
<pre id="transactionCount">Current Transaction Count: 0</pre>
</body>
</html>
|