mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Add benchmark for inserting and deleting a character
This commit is contained in:
@@ -7,20 +7,32 @@ Point = require 'point'
|
||||
require 'window'
|
||||
window.showConsole()
|
||||
|
||||
beforeEach ->
|
||||
window.keymap = new Keymap
|
||||
|
||||
afterEach ->
|
||||
$('#jasmine-content').empty()
|
||||
|
||||
keymap = new Keymap
|
||||
keymap.bindDefaultKeys()
|
||||
$(window).on 'keydown', (e) -> keymap.handleKeyEvent(e)
|
||||
keymap.bindKeys '*', 'meta-w': 'close'
|
||||
$(document).on 'close', -> window.close()
|
||||
|
||||
window.benchmark = (description, fn) ->
|
||||
it description, fn
|
||||
window.profile = (description, fn) ->
|
||||
window.benchmark(description, fn, true)
|
||||
|
||||
window.benchmark = (description, fn, profile=false) ->
|
||||
it description, ->
|
||||
count = 50
|
||||
total = measure ->
|
||||
console.profile(description) if profile
|
||||
_.times count, fn
|
||||
console.profileEnd(description) if profile
|
||||
avg = total / count
|
||||
report = "#{description}: #{total} / #{count} = #{avg}ms"
|
||||
|
||||
console.log report
|
||||
throw new Error(report)
|
||||
|
||||
window.measure = (fn) ->
|
||||
start = new Date().getTime()
|
||||
fn()
|
||||
new Date().getTime() - start
|
||||
|
||||
window.waitsForPromise = (fn) ->
|
||||
window.waitsFor (moveOn) ->
|
||||
|
||||
@@ -2,6 +2,17 @@ fs = require 'fs'
|
||||
require 'benchmark-helper'
|
||||
|
||||
describe "Editor", ->
|
||||
benchmark "inserting and deleting a character", ->
|
||||
editor = null
|
||||
|
||||
beforeEach ->
|
||||
window.rootViewParentSelector = '#jasmine-content'
|
||||
window.startup()
|
||||
editor = rootView.editor
|
||||
|
||||
afterEach ->
|
||||
window.shutdown()
|
||||
|
||||
profile "inserting and deleting a character", ->
|
||||
editor.hiddenInput.textInput('x')
|
||||
editor.backspace()
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ require 'jquery-extensions'
|
||||
# the DOM window.
|
||||
|
||||
windowAdditions =
|
||||
rootViewParentSelector: 'body'
|
||||
rootView: null
|
||||
keymap: null
|
||||
|
||||
@@ -45,7 +46,7 @@ windowAdditions =
|
||||
|
||||
attachRootView: (url) ->
|
||||
@rootView = new RootView {url}
|
||||
$('body').append @rootView
|
||||
$(@rootViewParentSelector).append @rootView
|
||||
|
||||
requireStylesheet: (path) ->
|
||||
fullPath = require.resolve(path)
|
||||
|
||||
Reference in New Issue
Block a user