Skip to content

Commit 68e58f1

Browse files
authored
Merge pull request #99 from Pradhyumna02/Update-Uploads-Microsoft
Update uploads Microsoft
2 parents e62a5aa + 16b6d2e commit 68e58f1

File tree

7 files changed

+54
-438
lines changed

7 files changed

+54
-438
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "speed-testjs",
3-
"version": "1.0.24",
3+
"version": "1.0.25",
44
"description": "measure internet bandwidth",
55
"main": "index.js",
66
"author": "Maulan Byron",

public/examples/upload/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ <h1 class="logo"></h1>
6161
<script src="lib/uploadHttpConcurrent.js"></script>
6262
<script src="lib/uploadProbeTest.js"></script>
6363
<script src="lib/uploadHttpConcurrentProgress.js"></script>
64-
<script src="lib/uploadHttpMicrosoft.js"></script>
6564
<script src="uilib/echarts.min.js"></script>
6665
<script src="/examples/upload/uploadApp.js"></script>
6766
</body>

public/examples/upload/uploadApp.js

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
var urls = [];
4242
var ports = [5020, 5021, 5022, 5023, 5024, 5025];
4343
var monitorInterval = 400;
44+
var isMicrosoftBrowser = false;
4445

4546
function initTest() {
4647
function addEvent(el, ev, fn) {
@@ -270,36 +271,21 @@
270271
}
271272

272273
var uploadHttpConcurrentProgress;
273-
var baseUrl;
274+
var baseUrl = (version === 'IPv6') ? testPlan.baseUrlIPv6NoPort : testPlan.baseUrlIPv4NoPort;
275+
for (var i = 0; i < ports.length; i++) {
276+
for (var b = 0; b < 6; b++) {
277+
urls.push('http://' + baseUrl + ':' + ports[i] + '/upload');
278+
}
279+
}
274280
//TODO needs to removed once we know the issues with ie
275281
if (navigator.appVersion.indexOf("MSIE") != -1 || navigator.appVersion.indexOf("Trident") != -1 || navigator.appVersion.indexOf("Edge") != -1) {
276-
var isIE = true;
277-
uploadSize = 17526506;
278-
uploadTestTimeout = 15000;
279-
uploadTestLength = 15000;
280-
uploadMovingAverage = 1;
281-
var uiMicrsoftMovingAverage = 2;
282+
isMicrosoftBrowser = true;
282283
}
283284

284-
if (isIE) {
285-
baseUrl = (version === 'IPv6') ? 'http://' + testPlan.baseUrlIPv6 : 'http://' + testPlan.baseUrlIPv4;
286-
287-
uploadHttpConcurrentProgress = new window.uploadHttpMicrosoft(baseUrl + '/upload', 'POST', uploadCurrentRuns, uploadTestTimeout, uploadTestLength,
288-
uploadMovingAverage, uiMicrsoftMovingAverage, uploadHttpOnComplete, uploadHttpOnProgress, uploadHttpOnError, uploadSize);
289-
uploadHttpConcurrentProgress.initiateTest();
290-
} else {
291-
baseUrl = (version === 'IPv6') ? testPlan.baseUrlIPv6NoPort : testPlan.baseUrlIPv4NoPort;
292-
for (var i = 0; i < ports.length; i++) {
293-
for (var b = 0; b < 6; b++) {
294-
urls.push('http://' + baseUrl + ':' + ports[i] + '/upload');
295-
}
296-
}
297-
298-
uploadHttpConcurrentProgress = new window.uploadHttpConcurrentProgress(urls, 'POST', uploadCurrentRuns, uploadTestTimeout, uploadTestLength, uploadMovingAverage, uploadHttpOnComplete, uploadHttpOnProgress,
299-
uploadHttpOnError, uploadSize, testPlan.maxuploadSize, monitorInterval);
285+
uploadHttpConcurrentProgress = new window.uploadHttpConcurrentProgress(urls, 'POST', uploadCurrentRuns, uploadTestTimeout, uploadTestLength, uploadMovingAverage, uploadHttpOnComplete, uploadHttpOnProgress,
286+
uploadHttpOnError, uploadSize, testPlan.maxuploadSize, monitorInterval, isMicrosoftBrowser);
300287

301-
uploadHttpConcurrentProgress.initiateTest();
302-
}
288+
uploadHttpConcurrentProgress.initiateTest();
303289
}
304290

305291
})();

public/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ <h1 class="logo"></h1>
8383
<script src="lib/uploadHttpConcurrent.js"></script>
8484
<script src="lib/uploadProbeTest.js"></script>
8585
<script src="lib/uploadHttpConcurrentProgress.js"></script>
86-
<script src="lib/uploadHttpMicrosoft.js"></script>
8786
<script src="uilib/echarts.min.js"></script>
8887
<script src="speed-testJS.js"></script>
8988
</body>

public/lib/uploadHttpConcurrentProgress.js

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* @param monitorInterval - monitor interval.
3737
*/
3838
function uploadHttpConcurrentProgress(urls, type, concurrentRuns, timeout, testLength, movingAverage, callbackComplete, callbackProgress, callbackError, size, maxuploadSize,
39-
monitorInterval) {
39+
monitorInterval, isMicrosoftBrowser) {
4040
this.urls = urls;
4141
this.size = size;
4242
this.type = type;
@@ -70,7 +70,14 @@
7070
//initializing the random data used for testing upload
7171
this._payload = null;
7272
this.uploadResults = [];
73-
73+
//boolean to see if the client is running the on microsoft browse
74+
this.isMicrosoftBrowser = isMicrosoftBrowser;
75+
//upload size for low bandwidth clients(microsoft browsers)
76+
this.lowBandwidthUploadSize = 50000;
77+
//upload size for high bandwidth clients(microsoft browsers)
78+
this.highBandwidthUploadSize = 5000000;
79+
//upload threshold value
80+
this.uploadThresholdValue = 50;
7481
}
7582

7683
/**
@@ -121,12 +128,29 @@
121128

122129
//store results
123130
this._storeResults(result);
124-
var uploadSize = (this.testLength - result.time) * result.loaded / result.time;
125131

126-
if (uploadSize > this.size) {
127-
this.size = uploadSize;
128-
if (this.size > this.maxuploadSize) {
129-
this.size = this.maxuploadSize;
132+
if (this.isMicrosoftBrowser) {
133+
134+
if (!this.isMaxUploadSize) {
135+
if (this.uploadResults[this.uploadResults.length - 1] > this.uploadThresholdValue) {
136+
//TODO need to dynamically increase the size.. may be look at the requests completed or the uploadSpeed
137+
this.isMaxUploadSize = true;
138+
//upload size used for high bandwidth clients of microsoft browsers
139+
this.size = this.highBandwidthUploadSize;
140+
} else {
141+
//upload size used for low bandwidth clients of microsoft browsers
142+
this.size = this.lowBandwidthUploadSize;
143+
}
144+
}
145+
146+
} else {
147+
var uploadSize = (this.testLength - result.time) * result.loaded / result.time;
148+
149+
if (uploadSize > this.size) {
150+
this.size = uploadSize;
151+
if (this.size > this.maxuploadSize) {
152+
this.size = this.maxuploadSize;
153+
}
130154
}
131155
}
132156

0 commit comments

Comments
 (0)