Browse files

Merge pull request #1041 from adobe/jason-sanjose/squashed-perf

JavaScript quick edit performance instrumentation & test suite
  • Loading branch information...
2 parents b7fa412 + 0679eda commit 17f78276f264d2a650335e4d00a4e66b8e53ecc3 @peterflynn peterflynn committed Jun 14, 2012
Showing with 342 additions and 189 deletions.
  1. +11 −5 src/document/DocumentManager.js
  2. +10 −10 src/editor/EditorManager.js
  3. +1 −13 src/editor/InlineTextEditor.js
  4. +9 −0 src/editor/InlineWidget.js
  5. +15 −13 src/editor/MultiRangeInlineEditor.js
  6. +12 −3 src/extensions/disabled/JavaScriptInlineEditor/JSUtils.js
  7. +75 −27 src/extensions/disabled/JavaScriptInlineEditor/main.js
  8. +169 −97 src/extensions/disabled/JavaScriptInlineEditor/unittests.js
  9. +0 −1 src/search/FindInFiles.js
  10. +5 −1 src/utils/PerfUtils.js
  11. +6 −6 test/SpecRunner.html
  12. +3 −3 test/SpecRunner.js
  13. +6 −4 test/perf/Performance-test.js
  14. +20 −6 test/perf/PerformanceReporter.js
  15. 0 test/{lib → thirdparty}/bootstrap2/css/bootstrap-responsive.css
  16. 0 test/{lib → thirdparty}/bootstrap2/css/bootstrap-responsive.min.css
  17. 0 test/{lib → thirdparty}/bootstrap2/css/bootstrap.css
  18. 0 test/{lib → thirdparty}/bootstrap2/css/bootstrap.min.css
  19. 0 test/{lib → thirdparty}/bootstrap2/img/glyphicons-halflings-white.png
  20. 0 test/{lib → thirdparty}/bootstrap2/img/glyphicons-halflings.png
  21. 0 test/{lib → thirdparty}/bootstrap2/js/bootstrap.js
  22. 0 test/{lib → thirdparty}/bootstrap2/js/bootstrap.min.js
  23. 0 test/{lib → thirdparty}/jasmine-core/example/SpecRunner.html
  24. 0 test/{lib → thirdparty}/jasmine-core/example/spec/PlayerSpec.js
  25. 0 test/{lib → thirdparty}/jasmine-core/example/spec/SpecHelper.js
  26. 0 test/{lib → thirdparty}/jasmine-core/example/src/Player.js
  27. 0 test/{lib → thirdparty}/jasmine-core/example/src/Song.js
  28. 0 test/{lib → thirdparty}/jasmine-core/jasmine-html.js
  29. 0 test/{lib → thirdparty}/jasmine-core/jasmine.css
  30. 0 test/{lib → thirdparty}/jasmine-core/jasmine.js
  31. 0 test/{lib → thirdparty}/jasmine-core/json2.js
  32. 0 test/{lib → thirdparty}/jasmine-core/spec
  33. 0 test/{lib → thirdparty}/jasmine-core/version.rb
  34. 0 test/{lib → thirdparty}/jasmine-jquery-1.3.1.js
View
16 src/document/DocumentManager.js
@@ -778,14 +778,16 @@ define(function (require, exports, module) {
* with a FileError if the file is not yet open and can't be read from disk.
*/
function getDocumentForPath(fullPath) {
- var result = new $.Deferred();
+ var result = new $.Deferred(),
+ doc = _openDocuments[fullPath];
- var perfTimerName = PerfUtils.markStart("getDocumentForPath:\t" + fullPath);
- result.always(function () {
- PerfUtils.addMeasurement(perfTimerName);
+ PerfUtils.markStart(PerfUtils.DOCUMENT_MANAGER_GET_DOCUMENT_FOR_PATH);
+ result.done(function () {
+ PerfUtils.addMeasurement(PerfUtils.DOCUMENT_MANAGER_GET_DOCUMENT_FOR_PATH);
+ }).fail(function () {
+ PerfUtils.finalizeMeasurement(PerfUtils.DOCUMENT_MANAGER_GET_DOCUMENT_FOR_PATH);
});
- var doc = _openDocuments[fullPath];
if (doc) {
result.resolve(doc);
} else {
@@ -799,6 +801,7 @@ define(function (require, exports, module) {
result.reject(fileError);
});
}
+
return result.promise();
}
@@ -980,6 +983,9 @@ define(function (require, exports, module) {
// Setup preferences
_prefs = PreferencesManager.getPreferenceStorage(PREFERENCES_CLIENT_ID);
$(exports).bind("currentDocumentChange workingSetAdd workingSetRemove", _savePreferences);
+
+ // Performance measurements
+ PerfUtils.createPerfMeasurement("DOCUMENT_MANAGER_GET_DOCUMENT_FOR_PATH", "DocumentManager.getDocumentForPath()");
// Initialize after ProjectManager is loaded
$(ProjectManager).on("initializeComplete", function (event, projectRoot) {
View
20 src/editor/EditorManager.js
@@ -101,13 +101,11 @@ define(function (require, exports, module) {
* @param {!boolean} makeMasterEditor If true, the Editor will set itself as the private "master"
* Editor for the Document. If false, the Editor will attach to the Document as a "slave."
* @param {!jQueryObject} container Container to add the editor to.
- * @param {!function} onInlineGesture Handler for Ctrl+E command (open/close inline, depending
- * on context)
* @param {{startLine: number, endLine: number}=} range If specified, range of lines within the document
* to display in this editor. Inclusive.
* @return {Editor} the newly created editor.
*/
- function _createEditorForDocument(doc, makeMasterEditor, container, onInlineGesture, range, additionalKeys) {
+ function _createEditorForDocument(doc, makeMasterEditor, container, range, additionalKeys) {
var mode = EditorUtils.getModeFromFileExtension(doc.file.fullPath);
var extraKeys = {
@@ -134,7 +132,7 @@ define(function (require, exports, module) {
* is created or rejected when no inline editors are available.
*/
function _openInlineWidget(editor) {
- PerfUtils.markStart(PerfUtils.OPEN_INLINE_EDITOR);
+ PerfUtils.markStart(PerfUtils.INLINE_EDITOR_OPEN);
// Run through inline-editor providers until one responds
var pos = editor.getCursorPos(),
@@ -151,16 +149,16 @@ define(function (require, exports, module) {
if (inlinePromise) {
inlinePromise.done(function (inlineWidget) {
editor.addInlineWidget(pos, inlineWidget);
- PerfUtils.addMeasurement(PerfUtils.OPEN_INLINE_EDITOR);
+ PerfUtils.addMeasurement(PerfUtils.INLINE_EDITOR_OPEN);
result.resolve();
}).fail(function () {
// terminate timer that was started above
- PerfUtils.finalizeMeasurement(PerfUtils.OPEN_INLINE_EDITOR);
+ PerfUtils.finalizeMeasurement(PerfUtils.INLINE_EDITOR_OPEN);
result.reject();
});
} else {
// terminate timer that was started above
- PerfUtils.finalizeMeasurement(PerfUtils.OPEN_INLINE_EDITOR);
+ PerfUtils.finalizeMeasurement(PerfUtils.INLINE_EDITOR_OPEN);
result.reject();
}
@@ -238,7 +236,7 @@ define(function (require, exports, module) {
function _createFullEditorForDocument(document) {
// Create editor; make it initially invisible
var container = _editorHolder.get(0);
- var editor = _createEditorForDocument(document, true, container, _openInlineWidget);
+ var editor = _createEditorForDocument(document, true, container);
editor.setVisible(false);
}
@@ -260,9 +258,9 @@ define(function (require, exports, module) {
*
* @return {{content:DOMElement, editor:Editor}}
*/
- function createInlineEditorForDocument(doc, range, inlineContent, closeThisInline, additionalKeys) {
+ function createInlineEditorForDocument(doc, range, inlineContent, additionalKeys) {
// Create the Editor
- var inlineEditor = _createEditorForDocument(doc, false, inlineContent, closeThisInline, range, additionalKeys);
+ var inlineEditor = _createEditorForDocument(doc, false, inlineContent, range, additionalKeys);
$(exports).triggerHandler("focusedEditorChange", inlineEditor);
@@ -516,7 +514,9 @@ define(function (require, exports, module) {
if (inlineWidget) {
// an inline widget's editor has focus, so close it
+ PerfUtils.markStart(PerfUtils.INLINE_EDITOR_CLOSE);
inlineWidget.close();
+ PerfUtils.addMeasurement(PerfUtils.INLINE_EDITOR_CLOSE);
} else {
// main editor has focus, so create an inline editor
_openInlineWidget(_currentEditor);
View
14 src/editor/InlineTextEditor.js
@@ -199,11 +199,6 @@ define(function (require, exports, module) {
endLine: endLine
};
- // close handler attached to each inline codemirror instance
- function closeThisInline() {
- self.close();
- }
-
// root container holding header & editor
var $wrapperDiv = $("<div/>");
var wrapperDiv = $wrapperDiv[0];
@@ -239,7 +234,7 @@ define(function (require, exports, module) {
// Create actual Editor instance
- var inlineInfo = EditorManager.createInlineEditorForDocument(doc, range, wrapperDiv, closeThisInline, additionalKeys);
+ var inlineInfo = EditorManager.createInlineEditorForDocument(doc, range, wrapperDiv, additionalKeys);
this.editors.push(inlineInfo.editor);
container.appendChild(wrapperDiv);
@@ -289,13 +284,6 @@ define(function (require, exports, module) {
return editor.hasFocus();
});
};
-
- /** Closes this inline widget and all its contained Editors */
- InlineTextEditor.prototype.close = function () {
- var shouldMoveFocus = this._editorHasFocus();
- EditorManager.closeInlineWidget(this.hostEditor, this, shouldMoveFocus);
- // closeInlineWidget() causes our onClosed() to be called
- };
// consolidate all dirty document updates
View
9 src/editor/InlineWidget.js
@@ -54,6 +54,15 @@ define(function (require, exports, module) {
InlineWidget.prototype.height = 0;
/**
+ * Closes this inline widget and all its contained Editors
+ */
+ InlineWidget.prototype.close = function () {
+ var shouldMoveFocus = this._editorHasFocus();
+ EditorManager.closeInlineWidget(this.hostEditor, this, shouldMoveFocus);
+ // closeInlineWidget() causes our onClosed() handler to be called
+ };
+
+ /**
* Called any time inline is closed, whether manually or automatically
*/
InlineWidget.prototype.onClosed = function () {
View
28 src/editor/MultiRangeInlineEditor.js
@@ -23,8 +23,8 @@
// FUTURE: Merge part (or all) of this class with InlineTextEditor
-/*jslint vars: true, plusplus: true, devel: true, browser: true, nomen: true, indent: 4, maxerr: 50 */
-/*global define: false, $: false, CodeMirror: false */
+/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
+/*global define, $, CodeMirror, window */
/**
* An inline editor for displaying and editing multiple text ranges. Each range corresponds to a
@@ -45,7 +45,8 @@ define(function (require, exports, module) {
EditorManager = require("editor/EditorManager"),
Commands = require("command/Commands"),
Strings = require("strings"),
- CommandManager = require("command/CommandManager");
+ CommandManager = require("command/CommandManager"),
+ PerfUtils = require("utils/PerfUtils");
/**
* Remove trailing "px" from a style size value.
@@ -124,30 +125,30 @@ define(function (require, exports, module) {
this._onClick = this._onClick.bind(this);
// Create DOM to hold editors and related list
- this.$editorsDiv = $(document.createElement('div')).addClass("inlineEditorHolder");
+ this.$editorsDiv = $(window.document.createElement('div')).addClass("inlineEditorHolder");
// Outer container for border-left and scrolling
- this.$relatedContainer = $(document.createElement("div")).addClass("related-container");
+ this.$relatedContainer = $(window.document.createElement("div")).addClass("related-container");
this._relatedContainerInserted = false;
this._relatedContainerInsertedHandler = this._relatedContainerInsertedHandler.bind(this);
// FIXME (jasonsj): deprecated event http://www.w3.org/TR/DOM-Level-3-Events/
this.$relatedContainer.on("DOMNodeInserted", this._relatedContainerInsertedHandler);
// List "selection" highlight
- this.$selectedMarker = $(document.createElement("div")).appendTo(this.$relatedContainer).addClass("selection");
+ this.$selectedMarker = $(window.document.createElement("div")).appendTo(this.$relatedContainer).addClass("selection");
// Inner container
- var $related = $(document.createElement("div")).appendTo(this.$relatedContainer).addClass("related");
+ var $related = $(window.document.createElement("div")).appendTo(this.$relatedContainer).addClass("related");
// Range list
- var $rangeList = $(document.createElement("ul")).appendTo($related);
+ var $rangeList = $(window.document.createElement("ul")).appendTo($related);
// create range list & add listeners for range textrange changes
var rangeItemText;
this._ranges.forEach(function (range, i) {
// Create list item UI
- var $rangeItem = $(document.createElement("li")).appendTo($rangeList);
+ var $rangeItem = $(window.document.createElement("li")).appendTo($rangeList);
_updateRangeLabel($rangeItem, range);
$rangeItem.mousedown(function () {
self.setSelectedIndex(i);
@@ -174,7 +175,7 @@ define(function (require, exports, module) {
this.$htmlContent.append(this.$editorsDiv).append(this.$relatedContainer);
// initialize position based on the main #editor-holder
- setTimeout(this._updateRelatedContainer, 0);
+ window.setTimeout(this._updateRelatedContainer, 0);
// Changes to the host editor should update the relatedContainer
// Note: normally it's not kosher to listen to changes on a specific editor,
@@ -213,6 +214,7 @@ define(function (require, exports, module) {
}
this._selectedRangeIndex = newIndex;
+
var $rangeItem = this._ranges[this._selectedRangeIndex].$listItem;
this._ranges[this._selectedRangeIndex].$listItem.toggleClass("selected", true);
@@ -249,7 +251,7 @@ define(function (require, exports, module) {
// scroll the selection to the rangeItem, use setTimeout to wait for DOM updates
var self = this;
- setTimeout(function () {
+ window.setTimeout(function () {
var containerHeight = self.$relatedContainer.height(),
itemTop = $rangeItem.position().top,
scrollTop = self.$relatedContainer.scrollTop();
@@ -350,7 +352,7 @@ define(function (require, exports, module) {
scrollerTop = scrollerOffset.top,
scrollerBottom = scrollerTop + hostScroller.clientHeight,
scrollerLeft = scrollerOffset.left,
- rightOffset = $(document.body).outerWidth() - (scrollerLeft + hostScroller.clientWidth);
+ rightOffset = $(window.document.body).outerWidth() - (scrollerLeft + hostScroller.clientWidth);
if (rcTop < scrollerTop || rcBottom > scrollerBottom) {
this.$relatedContainer.css("clip", "rect(" + Math.max(scrollerTop - rcTop, 0) + "px, auto, " +
(rcHeight - Math.max(rcBottom - scrollerBottom, 0)) + "px, auto)");
@@ -393,7 +395,7 @@ define(function (require, exports, module) {
* scroll position of the host editor to ensure that the cursor is visible.
*/
MultiRangeInlineEditor.prototype._ensureCursorVisible = function () {
- if ($.contains(this.editors[0].getRootElement(), document.activeElement)) {
+ if ($.contains(this.editors[0].getRootElement(), window.document.activeElement)) {
var cursorCoords = this.editors[0]._codeMirror.cursorCoords(),
lineSpaceOffset = $(this.editors[0]._getLineSpaceElement()).offset(),
rangeListOffset = this.$relatedContainer.offset();
View
15 src/extensions/disabled/JavaScriptInlineEditor/JSUtils.js
@@ -33,8 +33,9 @@ define(function (require, exports, module) {
// Load brackets modules
var Async = brackets.getModule("utils/Async"),
DocumentManager = brackets.getModule("document/DocumentManager"),
- StringUtils = brackets.getModule("utils/StringUtils"),
- NativeFileSystem = brackets.getModule("file/NativeFileSystem").NativeFileSystem;
+ NativeFileSystem = brackets.getModule("file/NativeFileSystem").NativeFileSystem,
+ PerfUtils = brackets.getModule("utils/PerfUtils"),
+ StringUtils = brackets.getModule("utils/StringUtils");
// Return an Array with names and offsets for all functions in the specified text
function _findAllFunctionsInText(text) {
@@ -145,6 +146,8 @@ define(function (require, exports, module) {
// Resolves with an Array of all function names and offsets for the specified file. Results
// may be cached.
function _getFunctionListForFile(fileInfo) {
+ PerfUtils.markStart(PerfUtils.FUNCTION_LIST_FOR_FILE);
+
var result = new $.Deferred();
var needToRead = false;
@@ -183,6 +186,10 @@ define(function (require, exports, module) {
} else {
_readFileAndGetFunctionList(fileInfo, result);
}
+
+ result.always(function () {
+ PerfUtils.addMeasurement(PerfUtils.FUNCTION_LIST_FOR_FILE);
+ });
return result.promise();
}
@@ -216,7 +223,6 @@ define(function (require, exports, module) {
.fail(function (error) {
oneFileResult.reject(error);
});
-
return oneFileResult.promise();
}
@@ -276,6 +282,9 @@ define(function (require, exports, module) {
return result;
}
+
+ // init
+ PerfUtils.createPerfMeasurement("FUNCTION_LIST_FOR_FILE", "JSUtils - Search 1 File");
exports._findAllMatchingFunctionsInText = _findAllMatchingFunctionsInText; // For testing only
exports.findMatchingFunctions = findMatchingFunctions;
View
102 src/extensions/disabled/JavaScriptInlineEditor/main.js
@@ -31,7 +31,8 @@ define(function (require, exports, module) {
// Brackets modules
var MultiRangeInlineEditor = brackets.getModule("editor/MultiRangeInlineEditor").MultiRangeInlineEditor,
FileIndexManager = brackets.getModule("project/FileIndexManager"),
- EditorManager = brackets.getModule("editor/EditorManager");
+ EditorManager = brackets.getModule("editor/EditorManager"),
+ PerfUtils = brackets.getModule("utils/PerfUtils");
// Local modules
var JSUtils = require("JSUtils");
@@ -56,6 +57,71 @@ define(function (require, exports, module) {
}
/**
+ * @private
+ * For unit and performance tests. Allows lookup by function name instead of editor offset
+ * without constructing an inline editor.
+ *
+ * @param {!string} functionName
+ * @return {$.Promise} a promise that will be resolved with an array of function offset information
+ */
+ function _findInProject(functionName) {
+ var result = new $.Deferred();
+
+ FileIndexManager.getFileInfoList("all")
+ .done(function (fileInfos) {
+ PerfUtils.markStart(PerfUtils.JAVASCRIPT_FIND_FUNCTION);
+
+ JSUtils.findMatchingFunctions(functionName, fileInfos)
+ .done(function (functions) {
+ PerfUtils.addMeasurement(PerfUtils.JAVASCRIPT_FIND_FUNCTION);
+ result.resolve(functions);
+ })
+ .fail(function () {
+ PerfUtils.finalizeMeasurement(PerfUtils.JAVASCRIPT_FIND_FUNCTION);
+ result.reject();
+ });
+ })
+ .fail(function () {
+ result.reject();
+ });
+
+ return result.promise();
+ }
+
+ /**
+ * @private
+ * For unit and performance tests. Allows lookup by function name instead of editor offset .
+ *
+ * @param {!Editor} hostEditor
+ * @param {!string} functionName
+ * @return {$.Promise} a promise that will be resolved with an InlineWidget
+ * or null if we're not going to provide anything.
+ */
+ function _createInlineEditor(hostEditor, functionName) {
+ var result = new $.Deferred();
+ PerfUtils.markStart(PerfUtils.JAVASCRIPT_INLINE_CREATE);
+
+ _findInProject(functionName).done(function (functions) {
+ if (functions && functions.length > 0) {
+ var jsInlineEditor = new MultiRangeInlineEditor(functions);
+ jsInlineEditor.load(hostEditor);
+
+ PerfUtils.addMeasurement(PerfUtils.JAVASCRIPT_INLINE_CREATE);
+ result.resolve(jsInlineEditor);
+ } else {
+ // No matching functions were found
+ PerfUtils.addMeasurement(PerfUtils.JAVASCRIPT_INLINE_CREATE);
+ result.reject();
+ }
+ }).fail(function () {
+ PerfUtils.finalizeMeasurement(PerfUtils.JAVASCRIPT_INLINE_CREATE);
+ result.reject();
+ });
+
+ return result.promise();
+ }
+
+ /**
* This function is registered with EditorManager as an inline editor provider. It creates an inline editor
* when the cursor is on a JavaScript function name, finds all functions that match the name
* and shows (one/all of them) in an inline editor.
@@ -83,34 +149,16 @@ define(function (require, exports, module) {
if (functionName === "") {
return null;
}
-
- var result = new $.Deferred();
-
- FileIndexManager.getFileInfoList("all")
- .done(function (fileInfos) {
-
- JSUtils.findMatchingFunctions(functionName, fileInfos)
- .done(function (functions) {
- if (functions && functions.length > 0) {
- var jsInlineEditor = new MultiRangeInlineEditor(functions);
- jsInlineEditor.load(hostEditor);
-
- result.resolve(jsInlineEditor);
- } else {
- // No matching functions were found
- result.reject();
- }
- })
- .fail(function () {
- result.reject();
- });
- })
- .fail(function () {
- result.reject();
- });
- return result.promise();
+ return _createInlineEditor(hostEditor, functionName);
}
+ // init
EditorManager.registerInlineEditProvider(javaScriptFunctionProvider);
+ PerfUtils.createPerfMeasurement("JAVASCRIPT_INLINE_CREATE", "JavaScript Inline Editor Creation");
+ PerfUtils.createPerfMeasurement("JAVASCRIPT_FIND_FUNCTION", "JavaScript Find Function");
+
+ // for unit tests only
+ exports._createInlineEditor = _createInlineEditor;
+ exports._findInProject = _findInProject;
});
View
266 src/extensions/disabled/JavaScriptInlineEditor/unittests.js
@@ -34,122 +34,123 @@ define(function (require, exports, module) {
FileIndexManager, // loaded from brackets.test
FileViewController, // loaded from brackets.test
ProjectManager, // loaded from brackets.test
+ PerfUtils, // loaded from brackets.test
FileUtils = brackets.getModule("file/FileUtils"),
NativeFileSystem = brackets.getModule("file/NativeFileSystem").NativeFileSystem,
- SpecRunnerUtils = brackets.getModule("spec/SpecRunnerUtils.js");
+ SpecRunnerUtils = brackets.getModule("spec/SpecRunnerUtils"),
+ PerformanceReporter = brackets.getModule("perf/PerformanceReporter");
// Local modules
var JSUtils = require("JSUtils");
- var extensionPath = FileUtils.getNativeModuleDirectoryPath(module);
-
- describe("JavaScriptInlineEditor", function () {
-
- var testPath = extensionPath + "/unittest-files",
- testWindow,
- initInlineTest;
+ var extensionPath = FileUtils.getNativeModuleDirectoryPath(module),
+ testPath = extensionPath + "/unittest-files",
+ testWindow,
+ initInlineTest;
- function rewriteProject(spec) {
- var result = new $.Deferred();
-
- FileIndexManager.getFileInfoList("all").done(function (allFiles) {
- // convert fileInfos to fullPaths
- allFiles = allFiles.map(function (fileInfo) {
- return fileInfo.fullPath;
- });
-
- // parse offsets and save
- SpecRunnerUtils.saveFilesWithoutOffsets(allFiles).done(function (offsetInfos) {
- spec.infos = offsetInfos;
+ function rewriteProject(spec) {
+ var result = new $.Deferred();
+
+ FileIndexManager.getFileInfoList("all").done(function (allFiles) {
+ // convert fileInfos to fullPaths
+ allFiles = allFiles.map(function (fileInfo) {
+ return fileInfo.fullPath;
+ });
- // install after function to restore file content
- spec.after(function () {
- var done = false;
-
- runs(function () {
- SpecRunnerUtils.saveFilesWithOffsets(spec.infos).done(function () {
- done = true;
- });
+ // parse offsets and save
+ SpecRunnerUtils.saveFilesWithoutOffsets(allFiles).done(function (offsetInfos) {
+ spec.infos = offsetInfos;
+
+ // install after function to restore file content
+ spec.after(function () {
+ var done = false;
+
+ runs(function () {
+ SpecRunnerUtils.saveFilesWithOffsets(spec.infos).done(function () {
+ done = true;
});
-
- waitsFor(function () { return done; }, "saveFilesWithOffsets timeout", 1000);
});
- result.resolve();
- }).fail(function () {
- result.reject();
+ waitsFor(function () { return done; }, "saveFilesWithOffsets timeout", 1000);
});
+
+ result.resolve();
+ }).fail(function () {
+ result.reject();
});
-
- return result.promise();
- }
+ });
- /**
- * Performs setup for an inline editor test. Parses offsets (saved to Spec.offsets) for all files in
- * the test project (testPath) and saves files back to disk without offset markup.
- * When finished, open an editor for the specified project relative file path
- * then attempts opens an inline editor at the given offset. Installs an after()
- * function restore all file content back to original state with offset markup.
- *
- * @param {!string} openFile Project relative file path to open in a main editor.
- * @param {!number} openOffset The offset index location within openFile to open an inline editor.
- * @param {?boolean} expectInline Use false to verify that an inline editor should not be opened. Omit otherwise.
- */
- var _initInlineTest = function (openFile, openOffset, expectInline, workingSet) {
- var allFiles,
- hostOpened = false,
- err = false,
- inlineOpened = null,
- spec = this,
- rewriteDone = false,
- rewriteErr = false;
-
- workingSet = workingSet || [];
-
- expectInline = (expectInline !== undefined) ? expectInline : true;
-
- SpecRunnerUtils.loadProjectInTestWindow(testPath);
-
- runs(function () {
- rewriteProject(spec)
- .done(function () { rewriteDone = true; })
- .fail(function () { rewriteErr = true; });
- });
-
- waitsFor(function () { return rewriteDone && !rewriteErr; }, "rewriteProject timeout", 1000);
-
- runs(function () {
- workingSet.push(openFile);
- SpecRunnerUtils.openProjectFiles(workingSet).done(function (documents) {
- hostOpened = true;
- }).fail(function () {
- err = true;
- });
+ return result.promise();
+ }
+
+ /**
+ * Performs setup for an inline editor test. Parses offsets (saved to Spec.offsets) for all files in
+ * the test project (testPath) and saves files back to disk without offset markup.
+ * When finished, open an editor for the specified project relative file path
+ * then attempts opens an inline editor at the given offset. Installs an after()
+ * function restore all file content back to original state with offset markup.
+ *
+ * @param {!string} openFile Project relative file path to open in a main editor.
+ * @param {!number} openOffset The offset index location within openFile to open an inline editor.
+ * @param {?boolean} expectInline Use false to verify that an inline editor should not be opened. Omit otherwise.
+ */
+ var _initInlineTest = function (openFile, openOffset, expectInline, workingSet) {
+ var allFiles,
+ hostOpened = false,
+ err = false,
+ inlineOpened = null,
+ spec = this,
+ rewriteDone = false,
+ rewriteErr = false;
+
+ workingSet = workingSet || [];
+
+ expectInline = (expectInline !== undefined) ? expectInline : true;
+
+ SpecRunnerUtils.loadProjectInTestWindow(testPath);
+
+ runs(function () {
+ rewriteProject(spec)
+ .done(function () { rewriteDone = true; })
+ .fail(function () { rewriteErr = true; });
+ });
+
+ waitsFor(function () { return rewriteDone && !rewriteErr; }, "rewriteProject timeout", 1000);
+
+ runs(function () {
+ workingSet.push(openFile);
+ SpecRunnerUtils.openProjectFiles(workingSet).done(function (documents) {
+ hostOpened = true;
+ }).fail(function () {
+ err = true;
});
+ });
+
+ waitsFor(function () { return hostOpened && !err; }, "FILE_OPEN timeout", 1000);
+
+ runs(function () {
+ var editor = EditorManager.getCurrentFullEditor();
- waitsFor(function () { return hostOpened && !err; }, "FILE_OPEN timeout", 1000);
+ // open inline editor at specified offset index
+ var inlineEditorResult = SpecRunnerUtils.openInlineEditorAtOffset(
+ editor,
+ spec.infos[openFile].offsets[openOffset]
+ );
- runs(function () {
- var editor = EditorManager.getCurrentFullEditor();
-
- // open inline editor at specified offset index
- var inlineEditorResult = SpecRunnerUtils.openInlineEditorAtOffset(
- editor,
- spec.infos[openFile].offsets[openOffset]
- );
-
- inlineEditorResult.done(function () {
- inlineOpened = true;
- }).fail(function () {
- inlineOpened = false;
- });
+ inlineEditorResult.done(function () {
+ inlineOpened = true;
+ }).fail(function () {
+ inlineOpened = false;
});
-
- waitsFor(function () {
- return (inlineOpened !== null) && (inlineOpened === expectInline);
- }, "inline editor timeout", 1000);
- };
+ });
+
+ waitsFor(function () {
+ return (inlineOpened !== null) && (inlineOpened === expectInline);
+ }, "inline editor timeout", 1000);
+ };
+
+ describe("JSQuickEdit", function () {
/*
*
@@ -591,5 +592,76 @@ define(function (require, exports, module) {
});
});
}); //describe("JS Parsing")
+
+ describe("Performance suite", function () {
+
+ this.performance = true;
+
+ var testPath = SpecRunnerUtils.getTestPath("/../../../brackets-scenario/jquery-ui/");
+
+ beforeEach(function () {
+ SpecRunnerUtils.createTestWindowAndRun(this, function (w) {
+ testWindow = w;
+ CommandManager = testWindow.brackets.test.CommandManager;
+ EditorManager = testWindow.brackets.test.EditorManager;
+ PerfUtils = testWindow.brackets.test.PerfUtils;
+ });
+ });
+
+ afterEach(function () {
+ SpecRunnerUtils.closeTestWindow();
+ });
+
+ it("should open inline editors", function () {
+ SpecRunnerUtils.loadProjectInTestWindow(testPath);
+
+ var extensionRequire,
+ JavaScriptQuickEdit,
+ done = false,
+ error = false,
+ i;
+
+ runs(function () {
+ extensionRequire = testWindow.brackets.getModule('utils/ExtensionLoader').getRequireContextForExtension('JavaScriptInlineEditor');
+ JavaScriptQuickEdit = extensionRequire("main");
+
+ SpecRunnerUtils.openProjectFiles(["ui/jquery.effects.core.js"]).done(function () {
+ done = true;
+ }).fail(function () {
+ error = true;
+ });
+ });
+
+ waitsFor(function () { return done && !error; }, 500);
+
+ var runCreateInlineEditor = function () {
+ done = error = false;
+
+ JavaScriptQuickEdit._createInlineEditor(EditorManager.getCurrentFullEditor(), "extend").done(function () {
+ done = true;
+ }).fail(function () {
+ error = true;
+ });
+ };
+
+ var waitForInlineEditor = function () { return done && !error; };
+
+ function logPerf() {
+ PerformanceReporter.logTestWindow(PerfUtils.DOCUMENT_MANAGER_GET_DOCUMENT_FOR_PATH, "Document creation during this search", "sum");
+ PerformanceReporter.logTestWindow(PerfUtils.JAVASCRIPT_FIND_FUNCTION, "jQuery UI project");
+ PerformanceReporter.logTestWindow(PerfUtils.JAVASCRIPT_INLINE_CREATE, "jQuery UI project");
+ PerformanceReporter.clearTestWindow();
+ }
+
+ // repeat 5 times
+ for (i = 0; i < 5; i++) {
+ runs(runCreateInlineEditor);
+ waitsFor(waitForInlineEditor, 500);
+
+ runs(logPerf);
+ }
+ });
+
+ });
});
});
View
1 src/search/FindInFiles.js
@@ -311,7 +311,6 @@ define(function (require, exports, module) {
return result.promise();
})
.done(function () {
- console.dir(searchResults);
_showSearchResults(searchResults);
})
.fail(function () {
View
6 src/utils/PerfUtils.js
@@ -326,8 +326,12 @@ define(function (require, exports, module) {
}
// create performance measurement constants
- createPerfMeasurement("OPEN_INLINE_EDITOR", "Open inline editor");
createPerfMeasurement("OPEN_FILE", "Open file");
+
+ createPerfMeasurement("INLINE_EDITOR_OPEN", "Open inline editor");
+ createPerfMeasurement("INLINE_EDITOR_CLOSE", "Close inline editor");
+
+ // extensions may create additional measurement constants during their lifecycle
exports.addMeasurement = addMeasurement;
exports.finalizeMeasurement = finalizeMeasurement;
View
12 test/SpecRunner.html
@@ -27,18 +27,18 @@
<head>
<title>Jasmine Spec Runner</title>
- <link href="lib/bootstrap2/css/bootstrap.min.css" rel="stylesheet">
- <link href="lib/bootstrap2/css/bootstrap-responsive.min.css" rel="stylesheet">
+ <link href="thirdparty/bootstrap2/css/bootstrap.min.css" rel="stylesheet">
+ <link href="thirdparty/bootstrap2/css/bootstrap-responsive.min.css" rel="stylesheet">
<link href="BootstrapReporter.css" rel="stylesheet">
- <script src="lib/jasmine-core/jasmine.js"></script>
- <script src="lib/jasmine-core/jasmine-html.js"></script>
- <script src="lib/jasmine-jquery-1.3.1.js"></script>
+ <script src="thirdparty/jasmine-core/jasmine.js"></script>
+ <script src="thirdparty/jasmine-core/jasmine-html.js"></script>
+ <script src="thirdparty/jasmine-jquery-1.3.1.js"></script>
<!-- Pre-load third party scripts that cannot be async loaded. -->
<script src="../src/thirdparty/jquery-1.7.min.js"></script>
<script src="../src/thirdparty/CodeMirror2/lib/codemirror.js"></script>
- <script src="lib/bootstrap2/js/bootstrap.min.js"></script>
+ <script src="thirdparty/bootstrap2/js/bootstrap.min.js"></script>
<script src="BootstrapReporter.js"></script>
<!-- All other scripts are loaded through require. -->
View
6 test/SpecRunner.js
@@ -38,11 +38,11 @@ define(function (require, exports, module) {
'use strict';
// Utility dependency
- var SpecRunnerUtils = require("spec/SpecRunnerUtils.js"),
+ var SpecRunnerUtils = require("spec/SpecRunnerUtils"),
+ PerformanceReporter = require("perf/PerformanceReporter").PerformanceReporter,
ExtensionLoader = require("utils/ExtensionLoader"),
FileUtils = require("file/FileUtils"),
- Menus = require("command/Menus"),
- PerformanceReporter = require("perf/PerformanceReporter").PerformanceReporter;
+ Menus = require("command/Menus");
// Load both top-level suites. Filtering is applied at the top-level as a filter to BootstrapReporter.
require("test/UnitTestSuite");
View
10 test/perf/Performance-test.js
@@ -42,7 +42,7 @@ define(function (require, exports, module) {
var jsLintPrevSetting;
describe("Performance Tests", function () {
-
+
this.performance = true;
// Note: this tests assumes that the "brackets-scenario" repo is in the same folder
@@ -59,14 +59,16 @@ define(function (require, exports, module) {
runs(function () {
CommandManager.execute(Commands.FILE_OPEN, {fullPath: testPath + path})
.done(function () {
- PerformanceReporter.logTestWindow(PerfUtils.OPEN_FILE, "Open file - " + path);
- PerformanceReporter.clearTestWindow();
-
didOpen = true;
})
.fail(function () { gotError = true; });
});
waitsFor(function () { return didOpen && !gotError; }, 1000);
+
+ runs(function () {
+ PerformanceReporter.logTestWindow(PerfUtils.OPEN_FILE, path);
+ PerformanceReporter.clearTestWindow();
+ });
}
beforeEach(function () {
View
26 test/perf/PerformanceReporter.js
@@ -37,7 +37,13 @@ define(function (require, exports, module) {
return SpecRunnerUtils.getTestWindow().brackets.test.PerfUtils;
}
- function logTestWindow(measure, name) {
+ /**
+ * Records a performance measurement from the test window for the current running spec.
+ * @param {!(PerfMeasurement|string)} measure
+ * @param {string} name An optional name or description to print with the measurement name
+ * @param {string} operation An optional operation to perform on the measurement data. Currently supports sum.
+ */
+ function logTestWindow(measure, name, operation) {
if (!currentSpec) {
return;
}
@@ -49,11 +55,18 @@ define(function (require, exports, module) {
throw new Error(measure.id + " measurement not found");
}
- if (!name && measure.name) {
- name = measure.name;
+ var printName = measure.name;
+
+ if (name) {
+ printName = printName + " - " + name;
+ }
+
+ if ((operation === "sum") && (Array.isArray(value))) {
+ value = value.reduce(function (a, b) { return a + b; });
+ printName = "Sum of all " + printName;
}
- records[currentSpec].push({ name: name, value: value });
+ records[currentSpec].push({ name: printName, value: value });
}
function clearTestWindow() {
@@ -70,14 +83,15 @@ define(function (require, exports, module) {
};
PerformanceReporter.prototype.reportSpecResults = function (spec) {
- if (spec.results().skipped) {
+ if (spec.results().skipped || (records[spec] && records[spec].length === 0)) {
return;
}
var $container = $("#results-container");
// add spec name
- $container.append($('<div class="alert alert-info"/>').text(spec.getFullName()));
+ var $specLink = $('<a href="?spec=' + encodeURIComponent(spec.getFullName()) + '"/>').text(spec.getFullName());
+ $container.append($('<div class="alert alert-info"/>').append($specLink));
// add table
var $table = $('<table class="table table-striped table-bordered table-condensed"><thead><tr><th>Measurement</th><th>Value</th></tr></thead></table>'),
View
0 ...b/bootstrap2/css/bootstrap-responsive.css → ...y/bootstrap2/css/bootstrap-responsive.css
File renamed without changes.
View
0 ...otstrap2/css/bootstrap-responsive.min.css → ...otstrap2/css/bootstrap-responsive.min.css
File renamed without changes.
View
0 test/lib/bootstrap2/css/bootstrap.css → test/thirdparty/bootstrap2/css/bootstrap.css
File renamed without changes.
View
0 test/lib/bootstrap2/css/bootstrap.min.css → ...irdparty/bootstrap2/css/bootstrap.min.css
File renamed without changes.
View
0 ...strap2/img/glyphicons-halflings-white.png → ...strap2/img/glyphicons-halflings-white.png
File renamed without changes
View
0 ...b/bootstrap2/img/glyphicons-halflings.png → ...y/bootstrap2/img/glyphicons-halflings.png
File renamed without changes
View
0 test/lib/bootstrap2/js/bootstrap.js → test/thirdparty/bootstrap2/js/bootstrap.js
File renamed without changes.
View
0 test/lib/bootstrap2/js/bootstrap.min.js → ...thirdparty/bootstrap2/js/bootstrap.min.js
File renamed without changes.
View
0 .../lib/jasmine-core/example/SpecRunner.html → ...arty/jasmine-core/example/SpecRunner.html
File renamed without changes.
View
0 ...b/jasmine-core/example/spec/PlayerSpec.js → ...y/jasmine-core/example/spec/PlayerSpec.js
File renamed without changes.
View
0 ...b/jasmine-core/example/spec/SpecHelper.js → ...y/jasmine-core/example/spec/SpecHelper.js
File renamed without changes.
View
0 test/lib/jasmine-core/example/src/Player.js → ...dparty/jasmine-core/example/src/Player.js
File renamed without changes.
View
0 test/lib/jasmine-core/example/src/Song.js → ...irdparty/jasmine-core/example/src/Song.js
File renamed without changes.
View
0 test/lib/jasmine-core/jasmine-html.js → test/thirdparty/jasmine-core/jasmine-html.js
File renamed without changes.
View
0 test/lib/jasmine-core/jasmine.css → test/thirdparty/jasmine-core/jasmine.css
File renamed without changes.
View
0 test/lib/jasmine-core/jasmine.js → test/thirdparty/jasmine-core/jasmine.js
File renamed without changes.
View
0 test/lib/jasmine-core/json2.js → test/thirdparty/jasmine-core/json2.js
File renamed without changes.
View
0 test/lib/jasmine-core/spec → test/thirdparty/jasmine-core/spec
File renamed without changes.
View
0 test/lib/jasmine-core/version.rb → test/thirdparty/jasmine-core/version.rb
File renamed without changes.
View
0 test/lib/jasmine-jquery-1.3.1.js → test/thirdparty/jasmine-jquery-1.3.1.js
File renamed without changes.

0 comments on commit 17f7827

Please sign in to comment.