Skip to content

Commit 7f3f040

Browse files
committed
Reformat all JS files using prettier
1 parent b17f4cb commit 7f3f040

File tree

297 files changed

+58685
-46917
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

297 files changed

+58685
-46917
lines changed

benchmarks/benchmark-runner.js

+42-39
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,75 @@
1-
const Chart = require('chart.js')
2-
const glob = require('glob')
3-
const fs = require('fs-plus')
4-
const path = require('path')
1+
const Chart = require('chart.js');
2+
const glob = require('glob');
3+
const fs = require('fs-plus');
4+
const path = require('path');
55

6-
module.exports = async ({test, benchmarkPaths}) => {
7-
document.body.style.backgroundColor = '#ffffff'
8-
document.body.style.overflow = 'auto'
6+
module.exports = async ({ test, benchmarkPaths }) => {
7+
document.body.style.backgroundColor = '#ffffff';
8+
document.body.style.overflow = 'auto';
99

10-
let paths = []
10+
let paths = [];
1111
for (const benchmarkPath of benchmarkPaths) {
1212
if (fs.isDirectorySync(benchmarkPath)) {
13-
paths = paths.concat(glob.sync(path.join(benchmarkPath, '**', '*.bench.js')))
13+
paths = paths.concat(
14+
glob.sync(path.join(benchmarkPath, '**', '*.bench.js'))
15+
);
1416
} else {
15-
paths.push(benchmarkPath)
17+
paths.push(benchmarkPath);
1618
}
1719
}
1820

1921
while (paths.length > 0) {
20-
const benchmark = require(paths.shift())({test})
21-
let results
22+
const benchmark = require(paths.shift())({ test });
23+
let results;
2224
if (benchmark instanceof Promise) {
23-
results = await benchmark
25+
results = await benchmark;
2426
} else {
25-
results = benchmark
27+
results = benchmark;
2628
}
2729

28-
const dataByBenchmarkName = {}
29-
for (const {name, duration, x} of results) {
30-
dataByBenchmarkName[name] = dataByBenchmarkName[name] || {points: []}
31-
dataByBenchmarkName[name].points.push({x, y: duration})
30+
const dataByBenchmarkName = {};
31+
for (const { name, duration, x } of results) {
32+
dataByBenchmarkName[name] = dataByBenchmarkName[name] || { points: [] };
33+
dataByBenchmarkName[name].points.push({ x, y: duration });
3234
}
3335

34-
const benchmarkContainer = document.createElement('div')
35-
document.body.appendChild(benchmarkContainer)
36+
const benchmarkContainer = document.createElement('div');
37+
document.body.appendChild(benchmarkContainer);
3638
for (const key in dataByBenchmarkName) {
37-
const data = dataByBenchmarkName[key]
39+
const data = dataByBenchmarkName[key];
3840
if (data.points.length > 1) {
39-
const canvas = document.createElement('canvas')
40-
benchmarkContainer.appendChild(canvas)
41+
const canvas = document.createElement('canvas');
42+
benchmarkContainer.appendChild(canvas);
4143
// eslint-disable-next-line no-new
4244
new Chart(canvas, {
4345
type: 'line',
4446
data: {
45-
datasets: [{label: key, fill: false, data: data.points}]
47+
datasets: [{ label: key, fill: false, data: data.points }]
4648
},
4749
options: {
4850
showLines: false,
49-
scales: {xAxes: [{type: 'linear', position: 'bottom'}]}
51+
scales: { xAxes: [{ type: 'linear', position: 'bottom' }] }
5052
}
51-
})
53+
});
5254

53-
const textualOutput = `${key}:\n\n` + data.points.map((p) => `${p.x}\t${p.y}`).join('\n')
54-
console.log(textualOutput)
55+
const textualOutput =
56+
`${key}:\n\n` + data.points.map(p => `${p.x}\t${p.y}`).join('\n');
57+
console.log(textualOutput);
5558
} else {
56-
const title = document.createElement('h2')
57-
title.textContent = key
58-
benchmarkContainer.appendChild(title)
59-
const duration = document.createElement('p')
60-
duration.textContent = `${data.points[0].y}ms`
61-
benchmarkContainer.appendChild(duration)
59+
const title = document.createElement('h2');
60+
title.textContent = key;
61+
benchmarkContainer.appendChild(title);
62+
const duration = document.createElement('p');
63+
duration.textContent = `${data.points[0].y}ms`;
64+
benchmarkContainer.appendChild(duration);
6265

63-
const textualOutput = `${key}: ${data.points[0].y}`
64-
console.log(textualOutput)
66+
const textualOutput = `${key}: ${data.points[0].y}`;
67+
console.log(textualOutput);
6568
}
6669

67-
await global.atom.reset()
70+
await global.atom.reset();
6871
}
6972
}
7073

71-
return 0
72-
}
74+
return 0;
75+
};
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,100 @@
1-
const {TextEditor, TextBuffer} = require('atom')
1+
const { TextEditor, TextBuffer } = require('atom');
22

3-
const MIN_SIZE_IN_KB = 0 * 1024
4-
const MAX_SIZE_IN_KB = 10 * 1024
5-
const SIZE_STEP_IN_KB = 1024
6-
const LINE_TEXT = 'Lorem ipsum dolor sit amet\n'
7-
const TEXT = LINE_TEXT.repeat(Math.ceil(MAX_SIZE_IN_KB * 1024 / LINE_TEXT.length))
3+
const MIN_SIZE_IN_KB = 0 * 1024;
4+
const MAX_SIZE_IN_KB = 10 * 1024;
5+
const SIZE_STEP_IN_KB = 1024;
6+
const LINE_TEXT = 'Lorem ipsum dolor sit amet\n';
7+
const TEXT = LINE_TEXT.repeat(
8+
Math.ceil((MAX_SIZE_IN_KB * 1024) / LINE_TEXT.length)
9+
);
810

9-
module.exports = async ({test}) => {
10-
const data = []
11+
module.exports = async ({ test }) => {
12+
const data = [];
1113

12-
document.body.appendChild(atom.workspace.getElement())
14+
document.body.appendChild(atom.workspace.getElement());
1315

14-
atom.packages.loadPackages()
15-
await atom.packages.activate()
16+
atom.packages.loadPackages();
17+
await atom.packages.activate();
1618

1719
for (let pane of atom.workspace.getPanes()) {
18-
pane.destroy()
20+
pane.destroy();
1921
}
2022

21-
for (let sizeInKB = MIN_SIZE_IN_KB; sizeInKB < MAX_SIZE_IN_KB; sizeInKB += SIZE_STEP_IN_KB) {
22-
const text = TEXT.slice(0, sizeInKB * 1024)
23-
console.log(text.length / 1024)
24-
25-
let t0 = window.performance.now()
26-
const buffer = new TextBuffer({text})
27-
const editor = new TextEditor({buffer, autoHeight: false, largeFileMode: true})
28-
atom.grammars.autoAssignLanguageMode(buffer)
29-
atom.workspace.getActivePane().activateItem(editor)
30-
let t1 = window.performance.now()
23+
for (
24+
let sizeInKB = MIN_SIZE_IN_KB;
25+
sizeInKB < MAX_SIZE_IN_KB;
26+
sizeInKB += SIZE_STEP_IN_KB
27+
) {
28+
const text = TEXT.slice(0, sizeInKB * 1024);
29+
console.log(text.length / 1024);
30+
31+
let t0 = window.performance.now();
32+
const buffer = new TextBuffer({ text });
33+
const editor = new TextEditor({
34+
buffer,
35+
autoHeight: false,
36+
largeFileMode: true
37+
});
38+
atom.grammars.autoAssignLanguageMode(buffer);
39+
atom.workspace.getActivePane().activateItem(editor);
40+
let t1 = window.performance.now();
3141

3242
data.push({
3343
name: 'Opening a large file',
3444
x: sizeInKB,
3545
duration: t1 - t0
36-
})
46+
});
3747

38-
const tickDurations = []
48+
const tickDurations = [];
3949
for (let i = 0; i < 20; i++) {
40-
await timeout(50)
41-
t0 = window.performance.now()
42-
await timeout(0)
43-
t1 = window.performance.now()
44-
tickDurations[i] = t1 - t0
50+
await timeout(50);
51+
t0 = window.performance.now();
52+
await timeout(0);
53+
t1 = window.performance.now();
54+
tickDurations[i] = t1 - t0;
4555
}
4656

4757
data.push({
4858
name: 'Max time event loop was blocked after opening a large file',
4959
x: sizeInKB,
5060
duration: Math.max(...tickDurations)
51-
})
61+
});
5262

53-
t0 = window.performance.now()
54-
editor.setCursorScreenPosition(editor.element.screenPositionForPixelPosition({
55-
top: 100,
56-
left: 30
57-
}))
58-
t1 = window.performance.now()
63+
t0 = window.performance.now();
64+
editor.setCursorScreenPosition(
65+
editor.element.screenPositionForPixelPosition({
66+
top: 100,
67+
left: 30
68+
})
69+
);
70+
t1 = window.performance.now();
5971

6072
data.push({
6173
name: 'Clicking the editor after opening a large file',
6274
x: sizeInKB,
6375
duration: t1 - t0
64-
})
76+
});
6577

66-
t0 = window.performance.now()
67-
editor.element.setScrollTop(editor.element.getScrollTop() + 100)
68-
t1 = window.performance.now()
78+
t0 = window.performance.now();
79+
editor.element.setScrollTop(editor.element.getScrollTop() + 100);
80+
t1 = window.performance.now();
6981

7082
data.push({
7183
name: 'Scrolling down after opening a large file',
7284
x: sizeInKB,
7385
duration: t1 - t0
74-
})
86+
});
7587

76-
editor.destroy()
77-
buffer.destroy()
78-
await timeout(10000)
88+
editor.destroy();
89+
buffer.destroy();
90+
await timeout(10000);
7991
}
8092

81-
atom.workspace.getElement().remove()
93+
atom.workspace.getElement().remove();
8294

83-
return data
84-
}
95+
return data;
96+
};
8597

86-
function timeout (duration) {
87-
return new Promise((resolve) => setTimeout(resolve, duration))
98+
function timeout(duration) {
99+
return new Promise(resolve => setTimeout(resolve, duration));
88100
}

0 commit comments

Comments
 (0)