Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.

Commit ddad614

Browse files
committed
illustrate parameters
1 parent a110d51 commit ddad614

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

test/perf.html

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,42 @@
55
<script src="../dist/es6-module-loader.js"></script>
66
<script>
77
/* PARAMETERS */
8-
var TREE_DEPTH = 2;
8+
var TREE_DEPTH = 10;
99
var NUM_MODULES = 1000;
1010

11+
/*
12+
TREE LOOKS LIKE -
13+
14+
MODULE NUM_MODULES
15+
|
16+
|
17+
------------------------------------- ...
18+
| | |
19+
MODULE 1 MODULE TREE_DEPTH ...
20+
| |
21+
MODULE 2 MODULE TREE_DEPTH + 2
22+
... ...
23+
MODULE TREE_DEPTH - 1 MODULE TREE_DEPTH * 2 - 1
24+
25+
THAT IS -
26+
DEPTH = TREE_DEPTH
27+
BREADTH = FLOOR(NUM_MODULES / TREE_DEPTH)
28+
29+
*/
30+
1131

1232
System.set('module0', System.newModule({}));
1333
System.instantiate = function(load) {
1434
var num = load.name.substr(6);
1535

1636
var deps = [];
17-
if (num % TREE_DEPTH > 0)
37+
38+
// the last module depends on all of them
39+
if (num == NUM_MODULES) {
40+
for (var i = 0; i < NUM_MODULES; i += TREE_DEPTH)
41+
deps.push('module' + i);
42+
}
43+
else if (num % TREE_DEPTH > 0)
1844
deps = ['module' + (num - 1)];
1945

2046
return {
@@ -32,11 +58,8 @@
3258

3359
for (var i = 1; i <= NUM_MODULES; i++)
3460
System.define('module' + i, "function q() {} var p = 5;\n // non-trivial code");
35-
var promises = [];
36-
for (var i = NUM_MODULES; i > 1; i--) {
37-
promises.push(System.import('module' + i));
38-
}
39-
Promise.all(promises).then(function() {
61+
62+
System.import('module' + NUM_MODULES).then(function() {
4063
document.body.innerHTML = ((Date.now() - startTime) / NUM_MODULES) + 'ms per module';
4164
}).catch(function(e) {
4265
setTimeout(function() {

0 commit comments

Comments
 (0)