mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-07 15:49:23 +03:00
Update benchmarks
This commit is contained in:
parent
31a9bb83cf
commit
2ca738453b
@ -73,8 +73,8 @@ window.clickEvent = (properties={}) ->
|
|||||||
|
|
||||||
window.mouseEvent = (type, properties) ->
|
window.mouseEvent = (type, properties) ->
|
||||||
if properties.point
|
if properties.point
|
||||||
{point, editor} = properties
|
{point, editorView} = properties
|
||||||
{top, left} = @pagePixelPositionForPoint(editor, point)
|
{top, left} = @pagePixelPositionForPoint(editorView, point)
|
||||||
properties.pageX = left + 1
|
properties.pageX = left + 1
|
||||||
properties.pageY = top + 1
|
properties.pageY = top + 1
|
||||||
properties.originalEvent ?= {detail: 1}
|
properties.originalEvent ?= {detail: 1}
|
||||||
@ -86,14 +86,14 @@ window.mousedownEvent = (properties={}) ->
|
|||||||
window.mousemoveEvent = (properties={}) ->
|
window.mousemoveEvent = (properties={}) ->
|
||||||
window.mouseEvent('mousemove', properties)
|
window.mouseEvent('mousemove', properties)
|
||||||
|
|
||||||
window.pagePixelPositionForPoint = (editor, point) ->
|
window.pagePixelPositionForPoint = (editorView, point) ->
|
||||||
point = Point.fromObject point
|
point = Point.fromObject point
|
||||||
top = editor.lines.offset().top + point.row * editor.lineHeight
|
top = editorView.lines.offset().top + point.row * editorView.lineHeight
|
||||||
left = editor.lines.offset().left + point.column * editor.charWidth - editor.lines.scrollLeft()
|
left = editorView.lines.offset().left + point.column * editorView.charWidth - editorView.lines.scrollLeft()
|
||||||
{ top, left }
|
{ top, left }
|
||||||
|
|
||||||
window.setEditorWidthInChars = (editor, widthInChars, charWidth=editor.charWidth) ->
|
window.seteditorViewWidthInChars = (editorView, widthInChars, charWidth=editorView.charWidth) ->
|
||||||
editor.width(charWidth * widthInChars + editor.lines.position().left)
|
editorView.width(charWidth * widthInChars + editorView.lines.position().left)
|
||||||
|
|
||||||
$.fn.resultOfTrigger = (type) ->
|
$.fn.resultOfTrigger = (type) ->
|
||||||
event = $.Event(type)
|
event = $.Event(type)
|
||||||
|
@ -2,8 +2,8 @@ require './benchmark-helper'
|
|||||||
{$, _, RootView} = require 'atom'
|
{$, _, RootView} = require 'atom'
|
||||||
TokenizedBuffer = require '../src/tokenized-buffer'
|
TokenizedBuffer = require '../src/tokenized-buffer'
|
||||||
|
|
||||||
describe "editor.", ->
|
describe "editorView.", ->
|
||||||
editor = null
|
editorView = null
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
window.rootViewParentSelector = '#jasmine-content'
|
window.rootViewParentSelector = '#jasmine-content'
|
||||||
@ -12,19 +12,19 @@ describe "editor.", ->
|
|||||||
|
|
||||||
rootView.width(1024)
|
rootView.width(1024)
|
||||||
rootView.height(768)
|
rootView.height(768)
|
||||||
rootView.openSync() # open blank editor
|
rootView.openSync()
|
||||||
editor = rootView.getActiveView()
|
editorView = rootView.getActiveView()
|
||||||
|
|
||||||
afterEach ->
|
afterEach ->
|
||||||
if editor.pendingDisplayUpdate
|
if editorView.pendingDisplayUpdate
|
||||||
waitsFor "editor to finish rendering", (done) ->
|
waitsFor "editor to finish rendering", (done) ->
|
||||||
editor.on 'editor:display-updated', done
|
editorView.on 'editor:display-updated', done
|
||||||
|
|
||||||
describe "keymap.", ->
|
describe "keymap.", ->
|
||||||
event = null
|
event = null
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
event = keydownEvent('x', target: editor.hiddenInput[0])
|
event = keydownEvent('x', target: editorView.hiddenInput[0])
|
||||||
|
|
||||||
benchmark "keydown-event-with-no-binding", 10, ->
|
benchmark "keydown-event-with-no-binding", 10, ->
|
||||||
keymap.handleKeyEvent(event)
|
keymap.handleKeyEvent(event)
|
||||||
@ -35,8 +35,8 @@ describe "editor.", ->
|
|||||||
|
|
||||||
describe "empty-file.", ->
|
describe "empty-file.", ->
|
||||||
benchmark "insert-delete", ->
|
benchmark "insert-delete", ->
|
||||||
editor.insertText('x')
|
editorView.insertText('x')
|
||||||
editor.backspace()
|
editorView.backspace()
|
||||||
|
|
||||||
describe "300-line-file.", ->
|
describe "300-line-file.", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@ -44,81 +44,81 @@ describe "editor.", ->
|
|||||||
|
|
||||||
describe "at-begining.", ->
|
describe "at-begining.", ->
|
||||||
benchmark "insert-delete", ->
|
benchmark "insert-delete", ->
|
||||||
editor.insertText('x')
|
editorView.insertText('x')
|
||||||
editor.backspace()
|
editorView.backspace()
|
||||||
|
|
||||||
benchmark "insert-delete-rehighlight", ->
|
benchmark "insert-delete-rehighlight", ->
|
||||||
editor.insertText('"')
|
editorView.insertText('"')
|
||||||
editor.backspace()
|
editorView.backspace()
|
||||||
|
|
||||||
describe "at-end.", ->
|
describe "at-end.", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
editor.moveCursorToBottom()
|
editorView.moveCursorToBottom()
|
||||||
|
|
||||||
benchmark "insert-delete", ->
|
benchmark "insert-delete", ->
|
||||||
editor.insertText('"')
|
editorView.insertText('"')
|
||||||
editor.backspace()
|
editorView.backspace()
|
||||||
|
|
||||||
describe "empty-vs-set-innerHTML.", ->
|
describe "empty-vs-set-innerHTML.", ->
|
||||||
[firstRow, lastRow] = []
|
[firstRow, lastRow] = []
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
firstRow = editor.getFirstVisibleScreenRow()
|
firstRow = editorView.getFirstVisibleScreenRow()
|
||||||
lastRow = editor.getLastVisibleScreenRow()
|
lastRow = editorView.getLastVisibleScreenRow()
|
||||||
|
|
||||||
benchmark "build-gutter-html.", 1000, ->
|
benchmark "build-gutter-html.", 1000, ->
|
||||||
editor.gutter.renderLineNumbers(null, firstRow, lastRow)
|
editorView.gutter.renderLineNumbers(null, firstRow, lastRow)
|
||||||
|
|
||||||
benchmark "set-innerHTML.", 1000, ->
|
benchmark "set-innerHTML.", 1000, ->
|
||||||
editor.gutter.renderLineNumbers(null, firstRow, lastRow)
|
editorView.gutter.renderLineNumbers(null, firstRow, lastRow)
|
||||||
editor.gutter.lineNumbers[0].innerHtml = ''
|
editorView.gutter.lineNumbers[0].innerHtml = ''
|
||||||
|
|
||||||
benchmark "empty.", 1000, ->
|
benchmark "empty.", 1000, ->
|
||||||
editor.gutter.renderLineNumbers(null, firstRow, lastRow)
|
editorView.gutter.renderLineNumbers(null, firstRow, lastRow)
|
||||||
editor.gutter.lineNumbers.empty()
|
editorView.gutter.lineNumbers.empty()
|
||||||
|
|
||||||
describe "positionLeftForLineAndColumn.", ->
|
describe "positionLeftForLineAndColumn.", ->
|
||||||
line = null
|
line = null
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
editor.scrollTop(2000)
|
editorView.scrollTop(2000)
|
||||||
editor.resetDisplay()
|
editorView.resetDisplay()
|
||||||
line = editor.lineElementForScreenRow(106)[0]
|
line = editorView.lineElementForScreenRow(106)[0]
|
||||||
|
|
||||||
describe "one-line.", ->
|
describe "one-line.", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
editor.clearCharacterWidthCache()
|
editorView.clearCharacterWidthCache()
|
||||||
|
|
||||||
benchmark "uncached", 5000, ->
|
benchmark "uncached", 5000, ->
|
||||||
editor.positionLeftForLineAndColumn(line, 106, 82)
|
editorView.positionLeftForLineAndColumn(line, 106, 82)
|
||||||
editor.clearCharacterWidthCache()
|
editorView.clearCharacterWidthCache()
|
||||||
|
|
||||||
benchmark "cached", 5000, ->
|
benchmark "cached", 5000, ->
|
||||||
editor.positionLeftForLineAndColumn(line, 106, 82)
|
editorView.positionLeftForLineAndColumn(line, 106, 82)
|
||||||
|
|
||||||
describe "multiple-lines.", ->
|
describe "multiple-lines.", ->
|
||||||
[firstRow, lastRow] = []
|
[firstRow, lastRow] = []
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
firstRow = editor.getFirstVisibleScreenRow()
|
firstRow = editorView.getFirstVisibleScreenRow()
|
||||||
lastRow = editor.getLastVisibleScreenRow()
|
lastRow = editorView.getLastVisibleScreenRow()
|
||||||
|
|
||||||
benchmark "cache-entire-visible-area", 100, ->
|
benchmark "cache-entire-visible-area", 100, ->
|
||||||
for i in [firstRow..lastRow]
|
for i in [firstRow..lastRow]
|
||||||
line = editor.lineElementForScreenRow(i)[0]
|
line = editorView.lineElementForScreenRow(i)[0]
|
||||||
editor.positionLeftForLineAndColumn(line, i, Math.max(0, editor.lineLengthForBufferRow(i)))
|
editorView.positionLeftForLineAndColumn(line, i, Math.max(0, editorView.lineLengthForBufferRow(i)))
|
||||||
|
|
||||||
describe "text-rendering.", ->
|
describe "text-rendering.", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
editor.scrollTop(2000)
|
editorView.scrollTop(2000)
|
||||||
|
|
||||||
benchmark "resetDisplay", 50, ->
|
benchmark "resetDisplay", 50, ->
|
||||||
editor.resetDisplay()
|
editorView.resetDisplay()
|
||||||
|
|
||||||
benchmark "htmlForScreenRows", 1000, ->
|
benchmark "htmlForScreenRows", 1000, ->
|
||||||
lastRow = editor.getLastScreenRow()
|
lastRow = editorView.getLastScreenRow()
|
||||||
editor.htmlForScreenRows(0, lastRow)
|
editorView.htmlForScreenRows(0, lastRow)
|
||||||
|
|
||||||
benchmark "htmlForScreenRows.htmlParsing", 50, ->
|
benchmark "htmlForScreenRows.htmlParsing", 50, ->
|
||||||
lastRow = editor.getLastScreenRow()
|
lastRow = editorView.getLastScreenRow()
|
||||||
html = editor.htmlForScreenRows(0, lastRow)
|
html = editorView.htmlForScreenRows(0, lastRow)
|
||||||
|
|
||||||
div = document.createElement('div')
|
div = document.createElement('div')
|
||||||
div.innerHTML = html
|
div.innerHTML = html
|
||||||
@ -126,44 +126,44 @@ describe "editor.", ->
|
|||||||
describe "gutter-api.", ->
|
describe "gutter-api.", ->
|
||||||
describe "getLineNumberElementsForClass.", ->
|
describe "getLineNumberElementsForClass.", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
editor.gutter.addClassToLine(20, 'omgwow')
|
editorView.gutter.addClassToLine(20, 'omgwow')
|
||||||
editor.gutter.addClassToLine(40, 'omgwow')
|
editorView.gutter.addClassToLine(40, 'omgwow')
|
||||||
|
|
||||||
benchmark "DOM", 20000, ->
|
benchmark "DOM", 20000, ->
|
||||||
editor.gutter.getLineNumberElementsForClass('omgwow')
|
editorView.gutter.getLineNumberElementsForClass('omgwow')
|
||||||
|
|
||||||
benchmark "getLineNumberElement.DOM", 20000, ->
|
benchmark "getLineNumberElement.DOM", 20000, ->
|
||||||
editor.gutter.getLineNumberElement(12)
|
editorView.gutter.getLineNumberElement(12)
|
||||||
|
|
||||||
benchmark "toggle-class", 2000, ->
|
benchmark "toggle-class", 2000, ->
|
||||||
editor.gutter.addClassToLine(40, 'omgwow')
|
editorView.gutter.addClassToLine(40, 'omgwow')
|
||||||
editor.gutter.removeClassFromLine(40, 'omgwow')
|
editorView.gutter.removeClassFromLine(40, 'omgwow')
|
||||||
|
|
||||||
describe "find-then-unset.", ->
|
describe "find-then-unset.", ->
|
||||||
classes = ['one', 'two', 'three', 'four']
|
classes = ['one', 'two', 'three', 'four']
|
||||||
|
|
||||||
benchmark "single-class", 200, ->
|
benchmark "single-class", 200, ->
|
||||||
editor.gutter.addClassToLine(30, 'omgwow')
|
editorView.gutter.addClassToLine(30, 'omgwow')
|
||||||
editor.gutter.addClassToLine(40, 'omgwow')
|
editorView.gutter.addClassToLine(40, 'omgwow')
|
||||||
editor.gutter.removeClassFromAllLines('omgwow')
|
editorView.gutter.removeClassFromAllLines('omgwow')
|
||||||
|
|
||||||
benchmark "multiple-class", 200, ->
|
benchmark "multiple-class", 200, ->
|
||||||
editor.gutter.addClassToLine(30, 'one')
|
editorView.gutter.addClassToLine(30, 'one')
|
||||||
editor.gutter.addClassToLine(30, 'two')
|
editorView.gutter.addClassToLine(30, 'two')
|
||||||
|
|
||||||
editor.gutter.addClassToLine(40, 'two')
|
editorView.gutter.addClassToLine(40, 'two')
|
||||||
editor.gutter.addClassToLine(40, 'three')
|
editorView.gutter.addClassToLine(40, 'three')
|
||||||
editor.gutter.addClassToLine(40, 'four')
|
editorView.gutter.addClassToLine(40, 'four')
|
||||||
|
|
||||||
for klass in classes
|
for klass in classes
|
||||||
editor.gutter.removeClassFromAllLines(klass)
|
editorView.gutter.removeClassFromAllLines(klass)
|
||||||
|
|
||||||
describe "line-htmlification.", ->
|
describe "line-htmlification.", ->
|
||||||
div = null
|
div = null
|
||||||
html = null
|
html = null
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
lastRow = editor.getLastScreenRow()
|
lastRow = editorView.getLastScreenRow()
|
||||||
html = editor.htmlForScreenRows(0, lastRow)
|
html = editorView.htmlForScreenRows(0, lastRow)
|
||||||
div = document.createElement('div')
|
div = document.createElement('div')
|
||||||
|
|
||||||
benchmark "setInnerHTML", 1, ->
|
benchmark "setInnerHTML", 1, ->
|
||||||
@ -178,40 +178,40 @@ describe "editor.", ->
|
|||||||
rootView.openSync('huge.js')
|
rootView.openSync('huge.js')
|
||||||
|
|
||||||
benchmark "moving-to-eof.", 1, ->
|
benchmark "moving-to-eof.", 1, ->
|
||||||
editor.moveCursorToBottom()
|
editorView.moveCursorToBottom()
|
||||||
|
|
||||||
describe "on-first-line.", ->
|
describe "on-first-line.", ->
|
||||||
benchmark "inserting-newline", 5, ->
|
benchmark "inserting-newline", 5, ->
|
||||||
editor.insertNewline()
|
editorView.insertNewline()
|
||||||
|
|
||||||
describe "on-last-visible-line.", ->
|
describe "on-last-visible-line.", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
editor.setCursorScreenPosition([editor.getLastVisibleScreenRow(), 0])
|
editorView.setCursorScreenPosition([editorView.getLastVisibleScreenRow(), 0])
|
||||||
|
|
||||||
benchmark "move-down-and-scroll", 300, ->
|
benchmark "move-down-and-scroll", 300, ->
|
||||||
editor.trigger 'move-down'
|
editorView.trigger 'move-down'
|
||||||
|
|
||||||
describe "at-eof.", ->
|
describe "at-eof.", ->
|
||||||
endPosition = null
|
endPosition = null
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
editor.moveCursorToBottom()
|
editorView.moveCursorToBottom()
|
||||||
endPosition = editor.getCursorScreenPosition()
|
endPosition = editorView.getCursorScreenPosition()
|
||||||
|
|
||||||
benchmark "move-to-beginning-of-word", ->
|
benchmark "move-to-beginning-of-word", ->
|
||||||
editor.moveCursorToBeginningOfWord()
|
editorView.moveCursorToBeginningOfWord()
|
||||||
editor.setCursorScreenPosition(endPosition)
|
editorView.setCursorScreenPosition(endPosition)
|
||||||
|
|
||||||
benchmark "insert", ->
|
benchmark "insert", ->
|
||||||
editor.insertText('x')
|
editorView.insertText('x')
|
||||||
|
|
||||||
describe "TokenizedBuffer.", ->
|
describe "TokenizedBuffer.", ->
|
||||||
describe "coffee-script-grammar.", ->
|
describe "coffee-script-grammar.", ->
|
||||||
[languageMode, buffer] = []
|
[languageMode, buffer] = []
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
editSession = benchmarkFixturesProject.openSync('medium.coffee')
|
editor = benchmarkFixturesProject.openSync('medium.coffee')
|
||||||
{ languageMode, buffer } = editSession
|
{ languageMode, buffer } = editor
|
||||||
|
|
||||||
benchmark "construction", 20, ->
|
benchmark "construction", 20, ->
|
||||||
new TokenizedBuffer(buffer, { languageMode, tabLength: 2})
|
new TokenizedBuffer(buffer, { languageMode, tabLength: 2})
|
||||||
|
Loading…
Reference in New Issue
Block a user