-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
38 lines (31 loc) · 915 Bytes
/
main.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
28
29
30
31
32
33
34
35
36
37
38
'use strict';
$(async function(){
const imgSmall = 'http://rootinc.github.io/images/flower-500k.jpg';
const imgBig = 'http://rootinc.github.io/images/road-3600k.jpg';
const
txtBox = $('#text'),
logStart = function(label){
let timeStart = new Date();
return () => {
txtBox.append(
`<h3>${label}: ${(new Date()).valueOf() - timeStart.valueOf()}</h3>`
);
};
}
//sequential
let logSeqTotalEnd = logStart('sequential total');
let logEnd1 = logStart(`sequential ${imgSmall}`);
await $.get({url:imgSmall, cache:false});
logEnd1();
let logEnd2 = logStart(`sequential ${imgBig}`);
await $.get({url:imgBig, cache:false});
logEnd2();
logSeqTotalEnd();
//concurrent
let logConcTotalEnd = logStart('concurrent total');
await* [
$.get({url:imgSmall, cache:false}),
$.get({url:imgBig, cache:false})
];
logConcTotalEnd();
});