Skip to content

Commit

Permalink
Add a TextEditor benchmark for large files construction
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Scandurra committed Oct 14, 2016
1 parent 40d9bc7 commit bb0a0cd
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions benchmarks/text-editor-large-file-construction.bench.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/** @babel */

import fs from 'fs'
import temp from 'temp'
import {TextEditor, TextBuffer} from 'atom'

export default function () {
const data = []
const maxLineCount = 10000
const step = 500
const lineText = 'Lorem ipsum dolor sit amet\n'
const sampleText = lineText.repeat(maxLineCount)
for (let lineCount = 0; lineCount <= maxLineCount; lineCount += step) {
const text = sampleText.slice(0, lineText.length * lineCount)
const buffer = new TextBuffer(text)
const t0 = window.performance.now()
const editor = new TextEditor({buffer, largeFileMode: true})
document.body.appendChild(editor.element)
const t1 = window.performance.now()
data.push({name: 'Opening and rendering a TextEditor', x: lineCount, duration: t1 - t0})
editor.element.remove()
editor.destroy()
}
return data
}

0 comments on commit bb0a0cd

Please sign in to comment.