forked from two10degrees/AzureSpeedTest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
227 lines (196 loc) · 8.9 KB
/
index.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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Azure Speed Test - Measure the latenecy to your nearest Microsoft Azure Data Center">
<meta name="author" content="Richard Astbury">
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<title>Azure Speed Test</title>
<link rel="icon" type="image/png" href="/favicon.png" />
<style>
.container {
width:970px;
}
</style>
</head>
<body>
<div class="container" style="background:whitesmoke">
<div><a href="http://www.two10degrees.com/"><img src="//two10degrees.blob.core.windows.net/two10degrees.png" class="pull-right"/></a></div>
<h1 style="color:grey;font-size:50px">Microsoft Azure Speed Test</h1>
</div>
<div class="container" id="wait" style="margin-top:75px">
<h2>The speed test is starting...</h2>
<p>We are measuring the latency from your web browser to the Blob Storage Service in each of the 15 Microsoft Azure Data Centers...</p>
</div>
<div class="container results" style="margin-top:30px;margin-bottom:50px;display:none">
<h3>Blob Storage Latency</h3>
<canvas id="myChart" width="970" height="400"></canvas>
Latency times are in milliseconds. Lower is better.
</div>
<div class="container results" style="display:none">
<div class="row">
<div class="col-md-6" id="table"></div>
<div class="col-md-6">
<p>It looks like your nearest Data Center is <span style="font-weight:bold" id="dc"></span>. <span id="cdn"></span></p>
<p> </p>
<p>Share your results with other people on twitter <span id="twitterbutton"></span></p>
<p> </p>
<p>Compare your speed with others by watching the <a href="https://twitter.com/search?q=%23AzureSpeedTest&src=hash&mode=realtime">#AzureSpeedTest</a> hashtag, or view the results <a href="http://azurespeedtestmaps.azurewebsites.net/">on a map</a>.</p>
<p> </p>
<p><a href="https://github.com/richorama/AzureSpeedTest">Fork</a> on GitHub.</p>
<p> </p>
<p>Created by <a href="https://www.twitter.com/richorama/">@richorama</a> at <a href="https://www.twitter.com/two10degrees/">@two10degrees</a>. Thanks to <a href="https://twitter.com/mickba">Mick Badran</a> for the storage accounts in Australia.</p>
<p> </p>
<p><small>The latency times are indicative only, and do not represent the maxium performance achievable from Microsoft Azure. Use this website purely as a tool to gauge which Azure Data Center could be the best for your location.<br/>© Two10degrees 2014</small></p>
</div>
</div>
</div>
<script>
var ctx = document.getElementById("myChart").getContext("2d");
var startTime = {};
var pingHistory = {};
var label = []
var locations = {
"speedtestwe": "West Europe",
"speedtestsea" : "Southeast Asia",
"speedtestea": "East Asia",
"speedtestnsus": "North Central US",
"speedtestne": "North Europe",
"speedtestscus": "South Central US",
"speedtestwus": "West US",
"speedtesteus": "East US",
"speedtestjpe": "Japan East",
"speedtestjpw": "Japan West",
"speedtestbs": "Brazil South",
"speedtestcus": "Central US",
"speedtesteus2": "East US 2",
"mickmel": "Australia Southeast",
"micksyd": "Australia East",
"cdn": "Content Delivery Network *"
};
var colours = {
"speedtestwe": "#FF0000",
"speedtestsea" : "#FF6600",
"speedtestea": "#FFCC00",
"speedtestnsus": "#CCFF00",
"speedtestne": "#66FF00",
"speedtestscus": "#333",
"speedtestwus": "#00FF66",
"speedtesteus": "#00FFCC",
"speedtestjpe": "#00CCFF",
"speedtestjpw": "#0066FF",
"speedtestbs": "#0000FF",
"speedtestcus": "#6600FF",
"speedtesteus2": "#CC00FF",
"mickmel": "#FF00CC",
"micksyd": "#666",
"cdn": "#000000"
}
$().ready(function(){
setInterval(run,3000)
});
function run(){
if (i > 2){
$("#wait").fadeOut("slow", function(){
$(".results").fadeIn("slow");
});
drawChart();
drawTables();
}
label.push(i.toString());
while (label.length > 20){
label.shift();
}
i += 1;
for (var x in locations){
if (!startTime[x]){
startTime[x] = new Date().getTime();
if (x === "cdn"){
$.ajax({
url: "http://az207485.vo.msecnd.net/cb.json",
dataType: "jsonp",
cache: false
});
} else {
$.ajax({
url: "https://" + x + ".blob.core.windows.net/cb.json",
dataType: "jsonp",
cache: false
});
}
}
}
}
function drawChart(){
var data = {
labels: label,
datasets : []
}
for (var x in pingHistory){
data.datasets.push({
fillColor : "rgba(255,255,255,0)",
strokeColor : colours[x],
pointColor : "rgba(220,220,220,1)",
pointStrokeColor : colours[x],
data : pingHistory[x]
});
}
//console.log(data);
new Chart(ctx).Line(data,{animation:false});
}
function drawTables(){
var avg = [];
for (var x in pingHistory){
var total = 0;
pingHistory[x].forEach(function(y){total += y});
avg.push({dc: locations[x], colour: colours[x], avg: total / pingHistory[x].length});
}
//console.log(avg);
var html = "";
avg.sort(function(a,b){return a.avg - b.avg});
avg.forEach(function(x){
html += "<tr><td style='border-left: 5px " + x.colour + " solid;'>" + x.dc + "</td><td>" + Math.round(x.avg) + "ms</td></tr>"
});
$("#table").html("<table width='970' class='table table-bordered'><tr><th>Data Center</th><th>Average Latency</th></tr>" + html + "</table>* The Content Delivery Network is only suitable for static content.");
var cdnCloser = (avg[0].dc === locations.cdn);
avg = avg.filter(function(x){ return x.dc !== locations.cdn});
drawTwitterLink(avg[0].dc, avg[0].avg, cdnCloser);
}
function drawTwitterLink(dc, ms, cdnCloser){
if (cdnCloser){
$("#cdn").html('There appears to be a <a href="http://azure.microsoft.com/en-gb/services/cdn/">CDN Node</a> nearer your location.');
}
$("#dc").html(dc);
dc = dc.replace(/[ ]/g, "%20");
$("#twitterbutton").html("<p><a href=\"https://twitter.com/intent/tweet?button_hashtag=AzureSpeedTest&text=My%20nearest%20%23Azure%20Data%20Center%20is%20" + dc + "%20(" + Math.round(ms) + "ms).%20Find%20out%20yours%20http%3A%2F%2Fazurespeedtest.azurewebsites.net%20#AzureSpeedTest\" class='btn btn-primary btn-large' data-size='large' data-related='two10degrees' data-dnt='true'>Tweet your results</a></p>");
}
function call(data){
if (!pingHistory[data]) pingHistory[data] = [];
pingHistory[data].push((new Date().getTime() - startTime[data]));
startTime[data] = undefined;
while (pingHistory[data].length > 20){
pingHistory[data].shift();
}
}
var i = 1;
</script>
<script src="//two10degrees.blob.core.windows.net/Chart.min.js"></script>
<script src="https://speedtestwe.blob.core.windows.net/foo.js"></script>
<script src="https://speedtestsea.blob.core.windows.net/foo.js"></script>
<script src="https://speedtestea.blob.core.windows.net/foo.js"></script>
<script src="https://speedtestnsus.blob.core.windows.net/foo.js"></script>
<script src="https://speedtestne.blob.core.windows.net/foo.js"></script>
<script src="https://speedtestscus.blob.core.windows.net/foo.js"></script>
<script src="https://speedtestwus.blob.core.windows.net/foo.js"></script>
<script src="https://speedtesteus.blob.core.windows.net/foo.js"></script>
<script src="https://speedtestjpe.blob.core.windows.net/foo.js"></script>
<script src="https://speedtestjpw.blob.core.windows.net/foo.js"></script>
<script src="https://speedtestbs.blob.core.windows.net/foo.js"></script>
<script src="https://speedtestcus.blob.core.windows.net/foo.js"></script>
<script src="https://speedtesteus2.blob.core.windows.net/foo.js"></script>
<script src="https://mickmel.blob.core.windows.net/foo.js"></script>
<script src="https://micksyd.blob.core.windows.net/foo.js"></script>
<script src="http://az207485.vo.msecnd.net/foo.js"></script>
</body>
</html>