Why are my rspec tests running slower in Ruby 1.9.2 than 1.8.7?

I use spork to test the Sinatra application, and with Ruby 1.9.2, tests run after about 3.5 seconds, but in Ruby 1.8.7 an average of 1.2 seconds. I really tried Ruby 1.9.3 and even JRuby, but they had some gem errors that I use. Is there a way to bring the performance of Ruby 1.9.2 rspec to 1.8.7?

My gemfile:

source :rubygems gem 'sinatra', '1.3.1' gem 'thin', '1.3.1' gem 'haml', '3.1.4' gem 'datamapper', '1.2.0' gem 'dm-postgres-adapter', '1.2.0' gem 'carrierwave', '0.5.8' gem 'carrierwave-datamapper', '0.2.0' group :test do gem "dm-sqlite-adapter" gem "spork" gem "rspec" gem "rack-test" end 

spec_helper.rb:

 require 'rubygems' require 'spork' require 'sinatra' require 'rack/test' require 'rspec' require File.join(File.dirname(__FILE__), '..', 'app.rb') require File.join(File.dirname(__FILE__), '..', 'model/model.rb') Spork.prefork do set :environment, :test set :files, "test_files" end Spork.each_run do RSpec.configure do |config| config.before(:each) { DataMapper.auto_migrate! } config.after(:all) do FileUtils.rm_rf(Dir["#{settings.root}/public/test_files"]) end end end 

thanks!

+6
source share
2 answers

There was a problem with how ruby ​​1.9.2 demanded files at startup: http://rhnh.net/2011/05/28/speeding-up-rails-startup-time

1.9.3 has a partial fix for this IIRC.

+2
source

Doesn't match rspec's own test: https://gist.github.com/939865 . It is assumed that it will be faster. It might be something slower on your stack.

+1
source

Source: https://habr.com/ru/post/903334/


All Articles