-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathTablesScalability.js
49 lines (47 loc) · 1.31 KB
/
TablesScalability.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
39
40
41
42
43
44
45
46
47
48
49
var m = require("mithril");
var BigOFactor = require("./BigOFactor");
var TablesScalability = function(tables) {
this.oninit = function(vnode) {
vnode.state.tables = tables;
vnode.state.tables.forEach(function(t) {
if (t.scalability != "?") {
t.bigO = new BigOFactor(t.scalability, t.rows);
}
})
}.bind(this);
this.view = function(vnode) {
var factor = 1;
return m("div",
m("h3", "Estimation (experimental!)"),
m("table.pure-table", [
m("thead",
m("tr", [
m("th", "Table"),
m("th", "Row count"),
m("th", "Estimated row count or scale factor"),
])
), // thead
m("tbody",
vnode.state.tables.map(function(o) {
var disabled = false;
if (o.bigO) {
factor *= o.bigO.factor(o.newRows);
} else {
disabled = true;
}
return m("tr",
m("td", o.name),
m("td", o.rows),
m("td", m("input", {value: o.newRows, oninput: o.setNewRows, disabled: disabled}))
)
})
) // tbody
]),
m("p",
"Latency scale factor: ",
m("strong", "~", factor.toFixed(2), "x")
)
)
}.bind(this);
}
module.exports = TablesScalability;