Add benchmark suite, which runs with ctrl-alt-meta-b

This commit is contained in:
Corey Johnson & Nathan Sobo 2012-03-07 18:21:07 -07:00
parent 423a4dc17d
commit 18c8c7e14f
9 changed files with 206 additions and 20 deletions

View File

@ -2,10 +2,10 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1050</int>
<string key="IBDocument.SystemVersion">11C74</string>
<string key="IBDocument.SystemVersion">11D50b</string>
<string key="IBDocument.InterfaceBuilderVersion">1938</string>
<string key="IBDocument.AppKitVersion">1138.23</string>
<string key="IBDocument.HIToolboxVersion">567.00</string>
<string key="IBDocument.AppKitVersion">1138.32</string>
<string key="IBDocument.HIToolboxVersion">568.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">1938</string>
@ -68,6 +68,15 @@
<reference key="NSOnImage" ref="293900348"/>
<reference key="NSMixedImage" ref="169361956"/>
</object>
<object class="NSMenuItem" id="426052086">
<reference key="NSMenu" ref="110575045"/>
<string key="NSTitle">Run Benchmarks</string>
<string key="NSKeyEquiv">b</string>
<int key="NSKeyEquivModMask">1835008</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="293900348"/>
<reference key="NSMixedImage" ref="169361956"/>
</object>
<object class="NSMenuItem" id="305640227">
<reference key="NSMenu" ref="110575045"/>
<string key="NSTitle">Quit</string>
@ -115,6 +124,14 @@
</object>
<int key="connectionID">449</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">runBenchmarks:</string>
<reference key="source" ref="1050"/>
<reference key="destination" ref="426052086"/>
</object>
<int key="connectionID">452</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@ -171,6 +188,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="238522557"/>
<reference ref="305640227"/>
<reference ref="426052086"/>
</object>
<reference key="parent" ref="694149608"/>
</object>
@ -189,6 +207,11 @@
<reference key="object" ref="305640227"/>
<reference key="parent" ref="110575045"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">450</int>
<reference key="object" ref="426052086"/>
<reference key="parent" ref="110575045"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@ -201,6 +224,7 @@
<string>29.IBPluginDependency</string>
<string>389.IBPluginDependency</string>
<string>441.IBPluginDependency</string>
<string>450.IBPluginDependency</string>
<string>56.IBPluginDependency</string>
<string>57.IBPluginDependency</string>
<string>58.IBPluginDependency</string>
@ -216,6 +240,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
@ -230,7 +255,7 @@
<reference key="dict.values" ref="755588897"/>
</object>
<nil key="sourceID"/>
<int key="maxID">449</int>
<int key="maxID">452</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@ -239,14 +264,35 @@
<string key="className">Atom</string>
<string key="superclassName">NSApplication</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">runSpecs:</string>
<string key="NS.object.0">id</string>
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>runBenchmarks:</string>
<string>runSpecs:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">runSpecs:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">runSpecs:</string>
<string key="candidateClassName">id</string>
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>runBenchmarks:</string>
<string>runSpecs:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBActionInfo">
<string key="name">runBenchmarks:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">runSpecs:</string>
<string key="candidateClassName">id</string>
</object>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
@ -262,10 +308,6 @@
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
<integer value="1050" key="NS.object.0"/>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
<real value="1060" key="NS.object.0"/>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
<integer value="3000" key="NS.object.0"/>
@ -281,8 +323,8 @@
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>{9, 8}</string>
<string>{7, 2}</string>
<string>{11, 11}</string>
<string>{10, 3}</string>
</object>
</object>
</data>

View File

@ -14,6 +14,7 @@ class ClientHandler;
- (void)open:(NSString *)path;
- (IBAction)runSpecs:(id)sender;
- (IBAction)runBenchmarks:(id)sender;
@end

View File

@ -5,6 +5,10 @@
#import "native_handler.h"
#import "client_handler.h"
@interface Atom ()
- (CefRefPtr<CefV8Context>)atomContext;
@end
// Provide the CefAppProtocol implementation required by CEF.
@implementation Atom
@ -63,13 +67,19 @@
}
- (void)open:(NSString *)path {
CefRefPtr<CefV8Context> atomContext = _clientHandler->GetBrowser()->GetMainFrame()->GetV8Context();
[[AtomController alloc] initWithPath:path atomContext:atomContext];
[[AtomController alloc] initWithPath:path atomContext:[self atomContext]];
}
- (IBAction)runSpecs:(id)sender {
CefRefPtr<CefV8Context> atomContext = _clientHandler->GetBrowser()->GetMainFrame()->GetV8Context();
[[AtomController alloc] initSpecsWithAtomContext:atomContext];
[[AtomController alloc] initSpecsWithAtomContext:[self atomContext]];
}
- (IBAction)runBenchmarks:(id)sender {
[[AtomController alloc] initBenchmarksWithAtomContext:[self atomContext]];
}
- (CefRefPtr<CefV8Context>)atomContext {
return _clientHandler->GetBrowser()->GetMainFrame()->GetV8Context();
}
- (void)applicationWillFinishLaunching:(NSNotification *)notification {

View File

@ -17,6 +17,7 @@ class ClientHandler;
- (id)initWithBootstrapScript:(NSString *)bootstrapScript atomContext:(CefRefPtr<CefV8Context>) context;
- (id)initWithPath:(NSString *)path atomContext:(CefRefPtr<CefV8Context>)atomContext;
- (id)initSpecsWithAtomContext:(CefRefPtr<CefV8Context>)atomContext;
- (id)initBenchmarksWithAtomContext:(CefRefPtr<CefV8Context>)atomContext;
- (void)createBrowser;

View File

@ -36,6 +36,10 @@
return [self initWithBootstrapScript:@"spec-bootstrap" atomContext:atomContext];
}
- (id)initBenchmarksWithAtomContext:(CefRefPtr<CefV8Context>)atomContext {
return [self initWithBootstrapScript:@"benchmark-bootstrap" atomContext:atomContext];
}
- (void)windowDidLoad {
[self.window setDelegate:self];
[self.window setReleasedWhenClosed:NO];

View File

@ -0,0 +1,24 @@
{$$} = require 'space-pen'
nakedLoad 'jasmine'
nakedLoad 'jasmine-html'
nakedLoad 'jasmine-focused'
$ = require 'jquery'
$('head').append $$ ->
@link rel: "stylesheet", type: "text/css", href: "static/jasmine.css"
$('body').append $$ ->
@div id: 'jasmine_runner'
@div id: 'jasmine-content'
jasmineEnv = jasmine.getEnv()
trivialReporter = new jasmine.TrivialReporter(document, 'jasmine_runner')
jasmineEnv.addReporter(trivialReporter)
jasmineEnv.specFilter = (spec) -> trivialReporter.specFilter(spec)
require 'benchmark-suite'
jasmineEnv.execute()

View File

@ -0,0 +1,96 @@
nakedLoad 'jasmine-jquery'
$ = require 'jquery'
_ = require 'underscore'
Keymap = require 'keymap'
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.waitsForPromise = (fn) ->
window.waitsFor (moveOn) ->
fn().done(moveOn)
window.eventPropertiesForPattern = (pattern) ->
[modifiers..., key] = pattern.split '-'
modifiers.push 'shift' if key == key.toUpperCase() and key.toUpperCase() != key.toLowerCase()
charCode = key.toUpperCase().charCodeAt 0
isNamedKey = key.length > 1
if isNamedKey
keyIdentifier = key
else
keyIdentifier = "U+00" + charCode.toString(16)
ctrlKey: 'ctrl' in modifiers
altKey: 'alt' in modifiers
shiftKey: 'shift' in modifiers
metaKey: 'meta' in modifiers
which: charCode
originalEvent:
keyIdentifier: keyIdentifier
window.keydownEvent = (pattern, properties={}) ->
event = $.Event "keydown", _.extend(eventPropertiesForPattern(pattern), properties)
event.keystroke = (new Keymap).keystrokeStringForEvent(event)
event
window.clickEvent = (properties={}) ->
$.Event "click", properties
window.mouseEvent = (type, properties) ->
if properties.point
{point, editor} = properties
{top, left} = @pagePixelPositionForPoint(editor, point)
properties.pageX = left + 1
properties.pageY = top + 1
properties.originalEvent ?= {detail: 1}
$.Event type, properties
window.mousedownEvent = (properties={}) ->
window.mouseEvent('mousedown', properties)
window.mousemoveEvent = (properties={}) ->
window.mouseEvent('mousemove', properties)
window.pagePixelPositionForPoint = (editor, point) ->
point = Point.fromObject point
top = editor.lines.offset().top + point.row * editor.lineHeight
left = editor.lines.offset().left + point.column * editor.charWidth - editor.lines.scrollLeft()
{ top, left }
window.setEditorWidthInChars = (editor, widthInChars, charWidth=editor.charWidth) ->
editor.width(charWidth * widthInChars + editor.lines.position().left)
$.fn.resultOfTrigger = (type) ->
event = $.Event(type)
this.trigger(event)
event.result
$.fn.enableKeymap = ->
@on 'keydown', (e) => window.keymap.handleKeyEvent(e)
$.fn.attachToDom = ->
$('#jasmine-content').append(this)
$.fn.textInput = (data) ->
event = document.createEvent 'TextEvent'
event.initTextEvent('textInput', true, true, window, data)
this.each -> this.dispatchEvent(event)

View File

@ -0,0 +1,7 @@
fs = require 'fs'
require 'benchmark-helper'
describe "Editor", ->
benchmark "inserting and deleting a character", ->

View File

@ -1,5 +1,6 @@
paths = [
"#{atom.loadPath}/spec"
"#{atom.loadPath}/benchmark"
"#{atom.loadPath}/src/stdlib"
"#{atom.loadPath}/src/atom"
"#{atom.loadPath}/src"