From a02af2a51f4c29f0cb069d8c96784478045fa2a3 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 6 Aug 2012 18:28:51 -0600 Subject: [PATCH] Add benchmark for TokenizedBuffer w/ new TextMateGrammar tokenization. SO SLOW! --- benchmark/benchmark-helper.coffee | 7 +++++++ benchmark/benchmark-suite.coffee | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/benchmark/benchmark-helper.coffee b/benchmark/benchmark-helper.coffee index 2d836313f..25dffeb6f 100644 --- a/benchmark/benchmark-helper.coffee +++ b/benchmark/benchmark-helper.coffee @@ -4,9 +4,14 @@ _ = require 'underscore' Keymap = require 'keymap' Point = require 'point' RootView = require 'root-view' +Project = require 'project' +TextMateBundle = require 'text-mate-bundle' require 'window' +requireStylesheet "jasmine.css" +TextMateBundle.loadAll() + RootView.prototype.loadUserConfiguration = -> keymap = new Keymap @@ -24,6 +29,8 @@ window.fbenchmark = (args...) -> window.benchmark(args..., focused: true) window.fpbenchmark = (args...) -> window.benchmark(args..., profile: true, focused: true) window.pfbenchmark = window.fpbenchmark +window.benchmarkFixturesProject = new Project(require.resolve 'benchmark/fixtures') + window.benchmark = (args...) -> description = args.shift() if typeof args[0] is 'number' diff --git a/benchmark/benchmark-suite.coffee b/benchmark/benchmark-suite.coffee index db66ec394..e599c410f 100644 --- a/benchmark/benchmark-suite.coffee +++ b/benchmark/benchmark-suite.coffee @@ -1,7 +1,7 @@ -Buffer = require 'buffer' -fs = require 'fs' require 'benchmark-helper' +fs = require 'fs' $ = require 'jquery' +TokenizedBuffer = require 'tokenized-buffer' describe "editor.", -> editor = null @@ -79,3 +79,15 @@ describe "editor.", -> benchmark "move-to-beginning-of-word", -> editor.moveCursorToBeginningOfWord() editor.setCursorScreenPosition(endPosition) + +describe "TokenizedBuffer.", -> + describe "coffee-script-grammar.", -> + [languageMode, buffer] = [] + + beforeEach -> + editSession = benchmarkFixturesProject.buildEditSessionForPath('medium.coffee') + { languageMode, buffer } = editSession + + pfbenchmark "construction", 5, -> + new TokenizedBuffer(buffer, { languageMode, tabText: ' '}) +