Skip to content

Commit

Permalink
IMP remove dom indices
Browse files Browse the repository at this point in the history
IMP inherit cache from factory
  • Loading branch information
ts-thomas committed Oct 29, 2019
1 parent e1ca662 commit 3aa75d5
Show file tree
Hide file tree
Showing 26 changed files with 1,269 additions and 1,176 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## 0.7.4
`improve` improve cache handler which gains overall performance up to 20%<br>
`improve` inherit cache from factory<br>
`improve` add fast path within reconciliation<br>
`improve` indices requires no sync anymore<br>
`change` remove dom indices, method access by index is now recommended (access by node is still supported but has extra costs, prevent looping via method access by node)<br>
`new` method ___dispatch___ to call/invoke an event handler manually<br>
`fix` external/internal stores<br>

## 0.7.3
Expand Down
138 changes: 99 additions & 39 deletions README.md

Large diffs are not rendered by default.

502 changes: 252 additions & 250 deletions bench/README.md

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions bench/bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ if(params["duration"] && (params["duration"].indexOf("run-") !== -1)){
}
else{

duration = parseFloat(params["duration"] || "3") * 1000;
duration = parseFloat(params["duration"] || "5") * 1000;
}

const hidden = params["hidden"] !== "false";
Expand Down Expand Up @@ -391,7 +391,7 @@ window.onload = function(){
item.test || (item.test = suite[lib]);
}

setTimeout(perform, 500);
setTimeout(perform, 200);
}
};

Expand Down Expand Up @@ -554,7 +554,7 @@ function perform(){
status = false;
}

let loops = 0, now = perf.now();
let loops = 0, now = 0;

if(status){

Expand All @@ -567,10 +567,15 @@ function perform(){
// return;
// }

const end = now + duration;
const end = perf.now() + duration;

for(let start, mem_start, mem; now < end; loops++){

if(runs && (runs === loops)){

break;
}

if(test.start) test.start(loops);
if(!internal && test.prepare) test.prepare(loops);

Expand All @@ -580,15 +585,10 @@ function perform(){
test.fn(clone);
now = perf.now();
mem = perf.memory.usedJSHeapSize - mem_start;
elapsed += now - start;
elapsed += (now - start);
if(mem > 0) memory += mem;

if(test.end) test.end(loops);

if(runs && (runs === loops + 1)){

break;
}
}

if(test.complete) test.complete();
Expand All @@ -602,16 +602,16 @@ function perform(){

if(window === window.top){

result.nodeValue = (str_results += (status ? test.name.padEnd(12) + String(Math.floor(1000 / elapsed * loops)).padStart(8) + " op/s, Memory:\t" + (memory ? Math.floor(memory / loops) : "-") : "- failed -") + "\n") + (current < queue.length ? "running..." : "");
result.nodeValue = (str_results += (status ? test.name.padEnd(12) + String(Math.floor(1000 / elapsed * loops)).padStart(8) + " op/s, Memory:\t" + (memory ? Math.ceil(memory / loops) : "-") : "- failed -") + "\n") + (current < queue.length ? "running..." : "");
}
else{

window.top.postMessage(test.name + "," + (status ? Math.floor(1000 / elapsed * loops) : 0) + "," + (status ? Math.floor(memory / loops) : 0), location.protocol + "//" + location.hostname) //"https://nextapps-de.github.io" "https://raw.githack.com"
window.top.postMessage(test.name + "," + (status ? Math.floor(1000 / elapsed * loops) : 0) + "," + (status ? Math.ceil(memory / loops) : 0), location.protocol + "//" + location.hostname) //"https://nextapps-de.github.io" "https://raw.githack.com"
}

if(current < queue.length){

setTimeout(perform, 500);
setTimeout(perform, 200);
}
else{

Expand Down
19 changes: 10 additions & 9 deletions bench/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h1>Benchmark of Web Templating Engines (Stress Test)</h1>
<table>
<tr>
<td>
<input type="button" click="start" value="Start">
<input type="button" id="start" click="start" value="Start">
</td>
<td>&emsp;</td>
<td>
Expand All @@ -48,29 +48,30 @@ <h1>Benchmark of Web Templating Engines (Stress Test)</h1>
<td>
Duration:
<select id="duration">
<!--
<optgroup label="run">
<option value="run-2">2 runs</option>
<option value="run-5">5 runs</option>
<option value="run-10">10 runs</option>
<option value="run-50">50 runs</option>
<option value="run-100">100 runs</option>
<option value="run-250">250 runs</option>
<option value="run-500">500 runs</option>
<option value="run-1000">1000 runs</option>
</optgroup>
<optgroup label="time">
-->
<option value="0.1">100 ms</option>
<option value="0.5">500 ms</option>
<option value="1">1 sec</option>
<option value="3" selected>3 sec</option>
<option value="5">5 sec</option>
<option value="3">3 sec</option>
<option value="5" selected>5 sec</option>
<option value="10">10 sec</option>
<option value="30">30 sec</option>
</optgroup>
<!--</optgroup>-->
</select>
</td>
<td>&emsp;</td>
<td>
Repeat:
<select change="repeat">
<select id="repeat">
<option value="1" selected>1</option>
<option value="2">2</option>
<option value="5">5</option>
Expand All @@ -82,7 +83,7 @@ <h1>Benchmark of Web Templating Engines (Stress Test)</h1>
</td>
<td>&emsp;</td>
<td>
<input type="checkbox" id="best" checked disabled> keep best run
<input type="checkbox" id="keep" checked> keep best run
</td>
</tr>
</table>
Expand Down
82 changes: 66 additions & 16 deletions bench/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
const mikado = Mikado(document.getElementById("result"), "row", options);
const list = Mikado(document.getElementById("lib"), "lib", options);

const modes = window.location.hash.indexOf("modes") !== -1;
let strict;
let modes = window.location.hash.indexOf("modes") !== -1;
let internal;
let keyed;
let keep;
let repeat;
let index = -1;

const lib = shuffle(modes ? [
let lib = shuffle(modes ? [

"mikado-cross-shared", "mikado-exclusive", "mikado-keyed",
"mikado-keyed-shared", "mikado-non-keyed", "mikado-proxy",
Expand Down Expand Up @@ -42,8 +45,6 @@

init(window.location.hash);

let index = -1;

document.getElementById("mode").options[keyed ? 1 : internal ? 2 : 0].selected = true;

if(modes){
Expand All @@ -56,8 +57,9 @@
if(target.value === "Start"){

index = -1;
repeat = document.getElementById("repeat").value;
target.value = "Stop";
setTimeout(runner, 100);
setTimeout(runner, 200);
}
else{

Expand All @@ -81,7 +83,7 @@
"remove", "toggle", "clear"
];

let current = new Array(lib.length);
const current = new Array(lib.length);

let size = {

Expand Down Expand Up @@ -131,10 +133,12 @@
function runner(){

const duration = document.getElementById("duration").value;
keep = document.getElementById("keep").checked;

index++;
current[index][test[2]] = "run...";
mikado.update(mikado.node(index), current[index]);
const tmp = Object.assign({}, current[index]);
tmp[test[2]] = "run...";
mikado.update(mikado.node(index), tmp);
iframe.src = "test/" + lib[index].toLowerCase() + "/" + (keyed ? "keyed.html" : strict ? "strict.html" : internal ? "internal.html" : "") + ("?duration=" + duration);
}

Expand Down Expand Up @@ -239,12 +243,43 @@

if(event.origin === location.protocol + "//" + location.hostname){ // "https://nextapps-de.github.io" "https://raw.githack.com"

//console.log(event.data);

const parts = event.data.split(",");

current[index][parts[0]] = parseInt(parts[1], 10);
current[index]["memory"] += parseInt(parts[2], 10);
let tmp = parseInt(parts[1], 10);

if(keep){

if(!current[index][parts[0]] || (tmp > current[index][parts[0]])){

current[index][parts[0]] = tmp;
}
}
else{

if(current[index][parts[0]]){

current[index][parts[0]] += tmp;
}
else{

current[index][parts[0]] = tmp;
}
}

if(!current[index][parts[0]]){
tmp = parseInt(parts[2], 10);

if(current[index]["memory"]){

current[index]["memory"] += tmp;
}
else{

current[index]["memory"] = tmp;
}

if((repeat === 1) && (!current[index][parts[0]])){

current[index][parts[0]] = "-failed-";
}
Expand All @@ -253,7 +288,8 @@

if(index < lib.length - 1){

setTimeout(runner, 200);
mikado.update(index, current[index]);
setTimeout(runner, 50);
}
else{

Expand All @@ -264,16 +300,30 @@
return b["score"] - a["score"];
});

for(let i = 0; i < lib.length; i++){

lib[i] = current[i]["name"];
}

mikado.render(current);
return;

if(--repeat > 0){

index = -1;
setTimeout(runner, 50);
}
else{

Mikado.dispatch("start", document.getElementById("start"));
}
}
}
else{

current[index][test[test.indexOf(parts[0]) + 1]] = "run...";
const tmp = Object.assign({}, current[index]);
tmp[test[test.indexOf(parts[0]) + 1]] = "run...";
mikado.update(index, tmp);
}

mikado.refresh(index);
}
}
};
Expand Down
Loading

0 comments on commit 3aa75d5

Please sign in to comment.