forked from kenigbolo/network-speed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_usage.js
27 lines (24 loc) · 848 Bytes
/
test_usage.js
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
const NetworkSpeed = require('./app.js');
const testNetworkSpeed = new NetworkSpeed();
async function getNetworkDownloadSpeed() {
const baseUrl = 'http://eu.httpbin.org/stream-bytes/500000';
const fileSizeInBytes = 500000;
const speed = await testNetworkSpeed.checkDownloadSpeed(baseUrl, fileSizeInBytes);
console.log(`Download Speed: ${JSON.stringify(speed)}`);
}
async function getNetworkUploadSpeed() {
const options = {
hostname: 'www.google.com',
port: 80,
path: '/catchers/544b09b4599c1d0200000289',
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
};
const fileSizeInBytes = 2000000
const speed = await testNetworkSpeed.checkUploadSpeed(options, fileSizeInBytes);
console.log(`Upload Speed: ${JSON.stringify(speed)}`);
}
getNetworkDownloadSpeed();
getNetworkUploadSpeed();