Skip to content

Commit fcfeca3

Browse files
committed
Merge branch 'fabioricali-doz'
2 parents 06608a8 + 8bbb0c8 commit fcfeca3

File tree

3 files changed

+61
-8
lines changed

3 files changed

+61
-8
lines changed

frameworks/keyed/doz/package-lock.json

Lines changed: 6 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frameworks/keyed/doz/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"homepage": "https://github.com/krausest/js-framework-benchmark#readme",
2727
"dependencies": {
28-
"doz": "3.4.1"
28+
"doz": "dozjs/doz#v5"
2929
},
3030
"devDependencies": {
3131
"webpack": "4.41.4",

frameworks/keyed/doz/src/utils.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
'use strict';
2+
const _random = (max) => {
3+
return Math.round(Math.random() * 1000) % max;
4+
};
5+
const updateData = (data, mod = 10) => {
6+
const newData = [...data];
7+
for (let i = 0; i < newData.length; i += 10) {
8+
newData[i] = Object.assign({}, newData[i], {label: newData[i].label + ' !!!'});
9+
}
10+
return newData
11+
};
12+
const buildData = (id, count = 1000) => {
13+
const adjectives = ["pretty", "large", "big", "small", "tall", "short", "long", "handsome", "plain", "quaint", "clean", "elegant", "easy", "angry", "crazy", "helpful", "mushy", "odd", "unsightly", "adorable", "important", "inexpensive", "cheap", "expensive", "fancy"];
14+
const colours = ["red", "yellow", "blue", "green", "pink", "brown", "purple", "brown", "white", "black", "orange"];
15+
const nouns = ["table", "chair", "house", "bbq", "desk", "car", "pony", "cookie", "sandwich", "burger", "pizza", "mouse", "keyboard"];
16+
const data = [];
17+
for (let i = 0; i < count; i++)
18+
data.push({
19+
id: id++,
20+
label: adjectives[_random(adjectives.length)] + " " + colours[_random(colours.length)] + " " + nouns[_random(nouns.length)]
21+
});
22+
return {data, id};
23+
};
24+
25+
module.exports = {
26+
add(id, data) {
27+
const newData = buildData(id, 1000);
28+
return {data: [...data, ...newData.data], id: newData.id};
29+
},
30+
run(id) {
31+
console.time(this.currentBench = 'run');
32+
this.getStore('list').rows = buildData(id).data;
33+
},
34+
runLots(id) {
35+
return buildData(id, 10000);
36+
},
37+
update(data) {
38+
return updateData(data);
39+
},
40+
swapRows(data) {
41+
const newData = [...data];
42+
if (newData.length > 998) {
43+
let temp = newData[1];
44+
newData[1] = newData[998];
45+
newData[998] = temp;
46+
}
47+
return newData;
48+
},
49+
deleteRow(data, id) {
50+
return data.filter(d => {
51+
return d.id !== id
52+
});
53+
}
54+
};

0 commit comments

Comments
 (0)