Skip to content

Commit

Permalink
Improve measurements of responsiveness in large file benchmark
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Sobo <nathan@github.com>
  • Loading branch information
maxbrunsfeld authored and Nathan Sobo committed Oct 14, 2016
1 parent 17c72d5 commit 465d8da
Showing 1 changed file with 56 additions and 27 deletions.
83 changes: 56 additions & 27 deletions benchmarks/text-editor-large-file-construction.bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,86 @@

import {TextEditor, TextBuffer} from 'atom'

const MAX_SIZE_IN_KB = 10 * 1024
const MIN_SIZE_IN_KB = 0 * 1024
const MAX_SIZE_IN_KB = 6 * 1024
const SIZE_STEP_IN_KB = 1024
const LINE_TEXT = 'Lorem ipsum dolor sit amet\n'
const CLICK_COUNT = 2
const TEXT = LINE_TEXT.repeat(Math.ceil(MAX_SIZE_IN_KB * 1024 / LINE_TEXT.length))

export default async function ({test}) {
const data = []

for (let sizeInKB = 0; sizeInKB < MAX_SIZE_IN_KB; sizeInKB += SIZE_STEP_IN_KB) {
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) {
const text = TEXT.slice(0, sizeInKB * 1024)
console.log(text.length / 1024)

const t0 = window.performance.now()
let t0 = window.performance.now()
const buffer = new TextBuffer(text)
const editor = new TextEditor({buffer, largeFileMode: true})
editor.element.style.height = "600px"
document.body.appendChild(editor.element)
const t1 = window.performance.now()
atom.workspace.getActivePane().activateItem(editor)
let t1 = window.performance.now()

data.push({
name: 'Opening and rendering a large file',
name: 'Opening a large file',
x: sizeInKB,
duration: t1 - t0
})

for (let i = 0; i < CLICK_COUNT; i++) {
const t2 = window.performance.now()
editor.setCursorScreenPosition(
editor.element.screenPositionForPixelPosition({
top: i * 20,
left: 0
})
)
const t3 = window.performance.now()

data.push({
name: 'Clicking somewhere onscreen after opening a large file',
x: sizeInKB,
duration: t3 - t2
})

await timeout(100)
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
}

editor.element.remove()
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()
editor.setFirstVisibleScreenRow(editor.getLastVisibleScreenRow() + 10)
t1 = window.performance.now()

data.push({
name: 'Scrolling down after opening a large file',
x: sizeInKB,
duration: t1 - t0
})

editor.destroy()
buffer.destroy()
await timeout(5000)
await timeout(10000)
}

workspaceElement.remove()

return data
}

Expand Down

0 comments on commit 465d8da

Please sign in to comment.