2016-10-13 17:14:55 +03:00
|
|
|
/** @babel */
|
|
|
|
|
|
|
|
import {TextEditor, TextBuffer} from 'atom'
|
|
|
|
|
2016-10-15 00:51:00 +03:00
|
|
|
const MIN_SIZE_IN_KB = 0 * 1024
|
2016-10-15 01:27:47 +03:00
|
|
|
const MAX_SIZE_IN_KB = 10 * 1024
|
2016-10-14 23:23:54 +03:00
|
|
|
const SIZE_STEP_IN_KB = 1024
|
|
|
|
const LINE_TEXT = 'Lorem ipsum dolor sit amet\n'
|
|
|
|
const TEXT = LINE_TEXT.repeat(Math.ceil(MAX_SIZE_IN_KB * 1024 / LINE_TEXT.length))
|
|
|
|
|
|
|
|
export default async function ({test}) {
|
|
|
|
const data = []
|
|
|
|
|
2016-10-15 00:51:00 +03:00
|
|
|
const workspaceElement = atom.views.getView(atom.workspace)
|
|
|
|
document.body.appendChild(workspaceElement)
|
|
|
|
|
|
|
|
atom.packages.loadPackages()
|
|
|
|
await atom.packages.activate()
|
|
|
|
|
|
|
|
for (let pane of atom.workspace.getPanes()) {
|
|
|
|
pane.destroy()
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let sizeInKB = MIN_SIZE_IN_KB; sizeInKB < MAX_SIZE_IN_KB; sizeInKB += SIZE_STEP_IN_KB) {
|
2016-10-14 23:23:54 +03:00
|
|
|
const text = TEXT.slice(0, sizeInKB * 1024)
|
|
|
|
console.log(text.length / 1024)
|
|
|
|
|
2016-10-15 00:51:00 +03:00
|
|
|
let t0 = window.performance.now()
|
2016-10-14 23:23:54 +03:00
|
|
|
const buffer = new TextBuffer(text)
|
|
|
|
const editor = new TextEditor({buffer, largeFileMode: true})
|
2016-10-15 00:51:00 +03:00
|
|
|
atom.workspace.getActivePane().activateItem(editor)
|
|
|
|
let t1 = window.performance.now()
|
2016-10-14 23:23:54 +03:00
|
|
|
|
|
|
|
data.push({
|
2016-10-15 00:51:00 +03:00
|
|
|
name: 'Opening a large file',
|
2016-10-14 23:23:54 +03:00
|
|
|
x: sizeInKB,
|
|
|
|
duration: t1 - t0
|
|
|
|
})
|
|
|
|
|
2016-10-15 00:51:00 +03:00
|
|
|
const tickDurations = []
|
|
|
|
for (let i = 0; i < 20; i++) {
|
|
|
|
await timeout(50)
|
|
|
|
t0 = window.performance.now()
|
|
|
|
await timeout(0)
|
|
|
|
t1 = window.performance.now()
|
|
|
|
tickDurations[i] = t1 - t0
|
2016-10-14 23:23:54 +03:00
|
|
|
}
|
|
|
|
|
2016-10-15 00:51:00 +03:00
|
|
|
data.push({
|
|
|
|
name: 'Max time event loop was blocked after opening a large file',
|
|
|
|
x: sizeInKB,
|
|
|
|
duration: Math.max(...tickDurations)
|
|
|
|
})
|
|
|
|
|
|
|
|
t0 = window.performance.now()
|
|
|
|
editor.setCursorScreenPosition(editor.element.screenPositionForPixelPosition({
|
|
|
|
top: 100,
|
|
|
|
left: 30
|
|
|
|
}))
|
|
|
|
t1 = window.performance.now()
|
|
|
|
|
|
|
|
data.push({
|
|
|
|
name: 'Clicking the editor after opening a large file',
|
|
|
|
x: sizeInKB,
|
|
|
|
duration: t1 - t0
|
|
|
|
})
|
|
|
|
|
|
|
|
t0 = window.performance.now()
|
2016-10-15 01:27:47 +03:00
|
|
|
editor.element.setScrollTop(editor.element.getScrollTop() + 100)
|
2016-10-15 00:51:00 +03:00
|
|
|
t1 = window.performance.now()
|
|
|
|
|
|
|
|
data.push({
|
|
|
|
name: 'Scrolling down after opening a large file',
|
|
|
|
x: sizeInKB,
|
|
|
|
duration: t1 - t0
|
|
|
|
})
|
|
|
|
|
2016-10-14 23:23:54 +03:00
|
|
|
editor.destroy()
|
|
|
|
buffer.destroy()
|
2016-10-15 00:51:00 +03:00
|
|
|
await timeout(10000)
|
2016-10-14 23:23:54 +03:00
|
|
|
}
|
|
|
|
|
2016-10-15 00:51:00 +03:00
|
|
|
workspaceElement.remove()
|
|
|
|
|
2016-10-14 23:23:54 +03:00
|
|
|
return data
|
|
|
|
}
|
|
|
|
|
|
|
|
function timeout (duration) {
|
|
|
|
return new Promise((resolve) => setTimeout(resolve, duration))
|
2016-10-13 17:14:55 +03:00
|
|
|
}
|