2012-08-28 02:36:36 +04:00
|
|
|
require 'benchmark-helper'
|
|
|
|
fs = require 'fs'
|
|
|
|
$ = require 'jquery'
|
2012-09-25 02:47:33 +04:00
|
|
|
_ = require 'underscore'
|
2012-08-28 02:36:36 +04:00
|
|
|
TokenizedBuffer = require 'tokenized-buffer'
|
|
|
|
|
|
|
|
describe "editor.", ->
|
|
|
|
editor = null
|
|
|
|
|
|
|
|
beforeEach ->
|
|
|
|
window.rootViewParentSelector = '#jasmine-content'
|
2012-10-31 22:50:28 +04:00
|
|
|
window.attachRootView(require.resolve('benchmark/fixtures'))
|
|
|
|
|
|
|
|
rootView.width(1024)
|
|
|
|
rootView.height(768)
|
|
|
|
rootView.open() # open blank editor
|
2012-08-28 02:36:36 +04:00
|
|
|
editor = rootView.getActiveEditor()
|
|
|
|
|
|
|
|
afterEach ->
|
|
|
|
$(window).off 'beforeunload'
|
|
|
|
window.shutdown()
|
2012-08-29 21:59:45 +04:00
|
|
|
atom.setRootViewStateForPath(rootView.project.getPath(), null)
|
2012-08-28 02:36:36 +04:00
|
|
|
|
2012-11-02 23:23:45 +04:00
|
|
|
describe "keymap.", ->
|
|
|
|
event = null
|
|
|
|
|
|
|
|
beforeEach ->
|
|
|
|
event = keydownEvent('x', target: editor.hiddenInput[0])
|
|
|
|
|
|
|
|
benchmark "keydown-event-with-no-binding", 10, ->
|
|
|
|
keymap.handleKeyEvent(event)
|
|
|
|
|
2012-08-28 02:36:36 +04:00
|
|
|
describe "opening-buffers.", ->
|
|
|
|
benchmark "300-line-file.", ->
|
|
|
|
buffer = rootView.project.bufferForPath('medium.coffee')
|
|
|
|
|
|
|
|
describe "empty-file.", ->
|
|
|
|
benchmark "insert-delete", ->
|
|
|
|
editor.insertText('x')
|
|
|
|
editor.backspace()
|
|
|
|
|
|
|
|
describe "300-line-file.", ->
|
|
|
|
beforeEach ->
|
2012-10-31 22:50:28 +04:00
|
|
|
rootView.open('medium.coffee')
|
2012-08-28 02:36:36 +04:00
|
|
|
|
|
|
|
describe "at-begining.", ->
|
|
|
|
benchmark "insert-delete", ->
|
|
|
|
editor.insertText('x')
|
|
|
|
editor.backspace()
|
|
|
|
|
|
|
|
benchmark "insert-delete-rehighlight", ->
|
|
|
|
editor.insertText('"')
|
|
|
|
editor.backspace()
|
|
|
|
|
|
|
|
describe "at-end.", ->
|
|
|
|
beforeEach ->
|
|
|
|
editor.moveCursorToBottom()
|
|
|
|
|
|
|
|
benchmark "insert-delete", ->
|
|
|
|
editor.insertText('"')
|
|
|
|
editor.backspace()
|
|
|
|
|
|
|
|
describe "9000-line-file.", ->
|
|
|
|
benchmark "opening.", 5, ->
|
2012-10-31 22:50:28 +04:00
|
|
|
rootView.open('huge.js')
|
2012-08-28 02:36:36 +04:00
|
|
|
|
|
|
|
describe "after-opening.", ->
|
|
|
|
beforeEach ->
|
2012-10-31 22:50:28 +04:00
|
|
|
rootView.open('huge.js')
|
2012-08-28 02:36:36 +04:00
|
|
|
|
|
|
|
benchmark "moving-to-eof.", 1, ->
|
|
|
|
editor.moveCursorToBottom()
|
|
|
|
|
|
|
|
describe "on-first-line.", ->
|
|
|
|
benchmark "inserting-newline", 5, ->
|
|
|
|
editor.insertNewline()
|
|
|
|
|
|
|
|
describe "on-last-visible-line.", ->
|
|
|
|
beforeEach ->
|
|
|
|
editor.setCursorScreenPosition([editor.getLastVisibleScreenRow(), 0])
|
|
|
|
|
|
|
|
benchmark "move-down-and-scroll", 300, ->
|
|
|
|
editor.trigger 'move-down'
|
|
|
|
|
|
|
|
describe "at-eof.", ->
|
|
|
|
endPosition = null
|
|
|
|
|
|
|
|
beforeEach ->
|
|
|
|
editor.moveCursorToBottom()
|
|
|
|
endPosition = editor.getCursorScreenPosition()
|
|
|
|
|
|
|
|
benchmark "move-to-beginning-of-word", ->
|
|
|
|
editor.moveCursorToBeginningOfWord()
|
|
|
|
editor.setCursorScreenPosition(endPosition)
|
|
|
|
|
2012-11-03 01:43:05 +04:00
|
|
|
benchmark "insert", ->
|
2012-10-31 22:34:18 +04:00
|
|
|
editor.insertText('x')
|
|
|
|
|
2012-08-28 02:36:36 +04:00
|
|
|
describe "TokenizedBuffer.", ->
|
|
|
|
describe "coffee-script-grammar.", ->
|
|
|
|
[languageMode, buffer] = []
|
|
|
|
|
|
|
|
beforeEach ->
|
|
|
|
editSession = benchmarkFixturesProject.buildEditSessionForPath('medium.coffee')
|
|
|
|
{ languageMode, buffer } = editSession
|
|
|
|
|
2012-09-25 02:47:33 +04:00
|
|
|
benchmark "construction", 20, ->
|
2012-10-11 21:25:04 +04:00
|
|
|
new TokenizedBuffer(buffer, { languageMode, tabLength: 2})
|