From 0d4562119f80cc36ea27620d42d995eb17e61252 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Tue, 29 Nov 2011 09:45:23 -0500 Subject: [PATCH] small speed optimization --- Gemfile | 2 ++ lib/jasmine/headless/files_list.rb | 6 +++--- spec/spec_helper.rb | 5 +++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 59c357c..f04a59b 100644 --- a/Gemfile +++ b/Gemfile @@ -19,3 +19,5 @@ gem 'jquery-rails' gem 'ejs' gem 'simplecov' +#gem 'perftools.rb' + diff --git a/lib/jasmine/headless/files_list.rb b/lib/jasmine/headless/files_list.rb index 7887713..7456559 100644 --- a/lib/jasmine/headless/files_list.rb +++ b/lib/jasmine/headless/files_list.rb @@ -203,7 +203,7 @@ module Jasmine::Headless end def expanded_dir(path) - Dir[path].collect { |file| File.expand_path(file) }.find_all { |path| File.file?(path) && path[extension_filter] } + Dir[path].find_all { |file| file[extension_filter] }.collect { |file| File.expand_path(file) }.find_all { |path| File.file?(path) } end def extension_filter @@ -221,11 +221,11 @@ module Jasmine::Headless end def src_dir - config_dir_or_pwd('src_dir') + @src_dir ||= config_dir_or_pwd('src_dir') end def spec_dir - config_dir_or_pwd('spec_dir') + @spec_dir ||= config_dir_or_pwd('spec_dir') end def spec_file_searches diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 54f9d56..17ad330 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,6 +3,11 @@ if ENV['COVERAGE'] SimpleCov.start end +if ENV['PROFILE'] + require 'perftools' + PerfTools::CpuProfiler.start("/tmp/jhw-profile") +end + require 'jasmine-headless-webkit' require 'fakefs/spec_helpers'