Skip to content

Commit 2d96cef

Browse files
committed
Merge branch 'leeoniya-domvm'
2 parents ff3d25d + 51ea31b commit 2d96cef

File tree

14 files changed

+116
-175
lines changed

14 files changed

+116
-175
lines changed
File renamed without changes.

domvm-v2.1.4-keyed/index.html renamed to domvm-v3.0.1-keyed/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5-
<title>domvm v2.1.4-keyed</title>
5+
<title>domvm v3.0.1-keyed</title>
66
<link href="/css/currentStyle.css" rel="stylesheet"/>
77
</head>
88
<body>

domvm-v2.1.4-keyed/package.json renamed to domvm-v3.0.1-keyed/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "js-framework-benchmark-domvm-keyed",
3-
"version": "2.1.4-keyed",
3+
"version": "3.0.1-keyed",
44
"description": "Benchmark for domvm framework (keyed)",
55
"scripts": {
66
"build-dev": "node build.js",
@@ -13,6 +13,6 @@
1313
"rollup-plugin-uglify": "*"
1414
},
1515
"dependencies": {
16-
"domvm": "git://github.com/leeoniya/domvm.git#eeb3690109fc6515b462bfaef2f81dbcb68a827a"
16+
"domvm": "git://github.com/leeoniya/domvm.git#2eefd1d5bb3cf4aa739f9afd44dfa3df1c690bb3"
1717
}
1818
}
Lines changed: 34 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,7 @@
11
import domvm from '../node_modules/domvm/dist/nano/domvm.nano.min.js';
2-
32
import {Store} from './store.es6';
43

5-
let startTime;
6-
let lastMeasure;
7-
8-
function startMeasure(name) {
9-
startTime = performance.now();
10-
lastMeasure = name;
11-
}
12-
13-
function stopMeasure() {
14-
var last = lastMeasure;
15-
16-
if (lastMeasure) {
17-
window.setTimeout(function () {
18-
lastMeasure = null;
19-
var stop = performance.now();
20-
var duration = 0;
21-
console.log(last+" took "+(stop-startTime));
22-
}, 0);
23-
}
24-
}
25-
26-
const h = domvm.defineElement;
4+
const h = (tag, arg1, arg2) => domvm.defineElement(tag, arg1, arg2, domvm.FIXED_BODY);
275
const v = domvm.defineView;
286
const store = new Store();
297

@@ -41,27 +19,25 @@ function App(vm) {
4119
}
4220

4321
function Jumbotron(vm) {
44-
vm.diff(_ => [0]);
22+
vm.config({diff: _ => 0});
4523

46-
let wrapMeasure = name => e => {
47-
startMeasure(name);
24+
let exec = name => e => {
4825
store[name]();
49-
vm.root().redraw(true);
50-
stopMeasure(name);
26+
vm.root().redraw();
5127
};
5228

53-
let run = wrapMeasure("run");
54-
let runLots = wrapMeasure("runLots");
55-
let add = wrapMeasure("add");
56-
let update = wrapMeasure("update");
57-
let clear = wrapMeasure("clear");
58-
let swapRows = wrapMeasure("swapRows");
29+
let run = exec("run");
30+
let runLots = exec("runLots");
31+
let add = exec("add");
32+
let update = exec("update");
33+
let clear = exec("clear");
34+
let swapRows = exec("swapRows");
5935

6036
return _ =>
6137
h(".jumbotron", [
6238
h(".row", [
6339
h(".col-md-6", [
64-
h("h1", "domvm v2.1.4 (keyed)")
40+
h("h1", "domvm v3.0.1 (keyed)")
6541
]),
6642
h(".col-md-6", [
6743
h(".row", [
@@ -91,22 +67,18 @@ function Jumbotron(vm) {
9167

9268
function Table(vm) {
9369
let select = (e, node) => {
94-
startMeasure("select");
9570
while (node.key == null)
9671
node = node.parent;
9772
store.select(node.key);
98-
vm.redraw(true); // sync redraw
99-
stopMeasure("select");
73+
vm.redraw();
10074
return false;
10175
};
10276

10377
let remove = (e, node) => {
104-
startMeasure("delete");
10578
while (node.key == null)
10679
node = node.parent;
10780
store.delete(node.key);
108-
vm.redraw(true);
109-
stopMeasure("delete");
81+
vm.redraw();
11082
return false;
11183
};
11284

@@ -116,28 +88,27 @@ function Table(vm) {
11688
".lbl": select,
11789
};
11890

119-
return _ =>
120-
h("table.table.table-hover.table-striped.test-data", {onclick: tableClick}, [
121-
h("tbody", {_flags: domvm.KEYED_LIST}, store.data.map(item =>
122-
v(Item, item, item.id)
123-
))
124-
]);
125-
}
126-
127-
function Item(vm, item) {
128-
vm.diff((vm, item) => [item.label, item.id === store.selected]);
129-
130-
return _ =>
131-
h("tr", {class: item.id === store.selected ? 'danger' : null}, [
132-
h("td.col-md-1", item.id),
133-
h("td.col-md-4", [
134-
h("a.lbl", item.label)
135-
]),
136-
h("td.col-md-1", [
137-
h("a.remove", [
138-
h("span.glyphicon.glyphicon-remove", {"aria-hidden": ""})
91+
return _ => {
92+
var items = domvm.lazyList(store.data, {
93+
key: item => item.id,
94+
diff: item => [item.label, item.id === store.selected],
95+
});
96+
97+
return h("table.table.table-hover.table-striped.test-data", {onclick: tableClick}, [
98+
h("tbody", {_flags: domvm.LAZY_LIST | domvm.KEYED_LIST}, items.map(item =>
99+
h("tr", {_key: item.id, class: item.id === store.selected ? 'danger' : null}, [
100+
h("td.col-md-1", item.id),
101+
h("td.col-md-4", [
102+
h("a.lbl", item.label)
103+
]),
104+
h("td.col-md-1", [
105+
h("a.remove", [
106+
h("span.glyphicon.glyphicon-remove", {"aria-hidden": ""})
107+
])
108+
]),
109+
h("td.col-md-6")
139110
])
140-
]),
141-
h("td.col-md-6")
111+
))
142112
]);
113+
};
143114
}
File renamed without changes.
File renamed without changes.

domvm-v2.1.4-non-keyed/index.html renamed to domvm-v3.0.1-non-keyed/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5-
<title>domvm v2.1.4-non-keyed</title>
5+
<title>domvm v3.0.1-non-keyed</title>
66
<link href="/css/currentStyle.css" rel="stylesheet"/>
77
</head>
88
<body>

domvm-v2.1.4-non-keyed/package.json renamed to domvm-v3.0.1-non-keyed/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "js-framework-benchmark-domvm-non-keyed",
3-
"version": "2.1.4-non-keyed",
2+
"name": "js-framework-benchmark-domvm-keyed",
3+
"version": "3.0.1-non-keyed",
44
"description": "Benchmark for domvm framework (non-keyed)",
55
"scripts": {
66
"build-dev": "node build.js",
@@ -13,6 +13,6 @@
1313
"rollup-plugin-uglify": "*"
1414
},
1515
"dependencies": {
16-
"domvm": "git://github.com/leeoniya/domvm.git#eeb3690109fc6515b462bfaef2f81dbcb68a827a"
16+
"domvm": "git://github.com/leeoniya/domvm.git#2eefd1d5bb3cf4aa739f9afd44dfa3df1c690bb3"
1717
}
1818
}
Lines changed: 33 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,7 @@
11
import domvm from '../node_modules/domvm/dist/nano/domvm.nano.min.js';
2-
32
import {Store} from './store.es6';
43

5-
let startTime;
6-
let lastMeasure;
7-
8-
function startMeasure(name) {
9-
startTime = performance.now();
10-
lastMeasure = name;
11-
}
12-
13-
function stopMeasure() {
14-
var last = lastMeasure;
15-
16-
if (lastMeasure) {
17-
window.setTimeout(function () {
18-
lastMeasure = null;
19-
var stop = performance.now();
20-
var duration = 0;
21-
console.log(last+" took "+(stop-startTime));
22-
}, 0);
23-
}
24-
}
25-
26-
const h = domvm.defineElement;
4+
const h = (tag, arg1, arg2) => domvm.defineElement(tag, arg1, arg2, domvm.FIXED_BODY);
275
const v = domvm.defineView;
286
const store = new Store();
297

@@ -41,27 +19,25 @@ function App(vm) {
4119
}
4220

4321
function Jumbotron(vm) {
44-
vm.diff(_ => [0]);
22+
vm.config({diff: _ => 0});
4523

46-
let wrapMeasure = name => e => {
47-
startMeasure(name);
24+
let exec = name => e => {
4825
store[name]();
49-
vm.root().redraw(true);
50-
stopMeasure(name);
26+
vm.root().redraw();
5127
};
5228

53-
let run = wrapMeasure("run");
54-
let runLots = wrapMeasure("runLots");
55-
let add = wrapMeasure("add");
56-
let update = wrapMeasure("update");
57-
let clear = wrapMeasure("clear");
58-
let swapRows = wrapMeasure("swapRows");
29+
let run = exec("run");
30+
let runLots = exec("runLots");
31+
let add = exec("add");
32+
let update = exec("update");
33+
let clear = exec("clear");
34+
let swapRows = exec("swapRows");
5935

6036
return _ =>
6137
h(".jumbotron", [
6238
h(".row", [
6339
h(".col-md-6", [
64-
h("h1", "domvm v2.1.4 (non-keyed)")
40+
h("h1", "domvm v3.0.1 (non-keyed)")
6541
]),
6642
h(".col-md-6", [
6743
h(".row", [
@@ -91,22 +67,18 @@ function Jumbotron(vm) {
9167

9268
function Table(vm) {
9369
let select = (e, node) => {
94-
startMeasure("select");
9570
while (node.data == null)
9671
node = node.parent;
9772
store.select(node.data);
98-
vm.redraw(true); // sync redraw
99-
stopMeasure("select");
73+
vm.redraw();
10074
return false;
10175
};
10276

10377
let remove = (e, node) => {
104-
startMeasure("delete");
10578
while (node.data == null)
10679
node = node.parent;
10780
store.delete(node.data);
108-
vm.redraw(true);
109-
stopMeasure("delete");
81+
vm.redraw();
11082
return false;
11183
};
11284

@@ -116,28 +88,26 @@ function Table(vm) {
11688
".lbl": select,
11789
};
11890

119-
return _ =>
120-
h("table.table.table-hover.table-striped.test-data", {onclick: tableClick}, [
121-
h("tbody", store.data.map(item =>
122-
v(Item, item, false)
123-
))
124-
]);
125-
}
126-
127-
function Item(vm) {
128-
vm.diff((vm, item) => [item.label, item.id, item.id === store.selected]);
129-
130-
return (vm, item) =>
131-
h("tr", {class: item.id === store.selected ? 'danger' : null, _data: item.id}, [
132-
h("td.col-md-1", item.id),
133-
h("td.col-md-4", [
134-
h("a.lbl", item.label)
135-
]),
136-
h("td.col-md-1", [
137-
h("a.remove", [
138-
h("span.glyphicon.glyphicon-remove", {"aria-hidden": ""})
91+
return _ => {
92+
var items = domvm.lazyList(store.data, {
93+
diff: item => [item.label, item.id === store.selected, item.id],
94+
});
95+
96+
return h("table.table.table-hover.table-striped.test-data", {onclick: tableClick}, [
97+
h("tbody", {_flags: domvm.LAZY_LIST}, items.map(item =>
98+
h("tr", {_data: item.id, class: item.id === store.selected ? 'danger' : null}, [
99+
h("td.col-md-1", item.id),
100+
h("td.col-md-4", [
101+
h("a.lbl", item.label)
102+
]),
103+
h("td.col-md-1", [
104+
h("a.remove", [
105+
h("span.glyphicon.glyphicon-remove", {"aria-hidden": ""})
106+
])
107+
]),
108+
h("td.col-md-6")
139109
])
140-
]),
141-
h("td.col-md-6")
110+
))
142111
]);
112+
};
143113
}
File renamed without changes.

0 commit comments

Comments
 (0)