Last active
November 26, 2015 07:50
-
-
Save kazu69/8628e1ed92533fd61881 to your computer and use it in GitHub Desktop.
rspec with Stackprof http://blog.kazu69.net/2015/10/20/use-stackprof-improve-performance-of-rspec/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Gemfile | |
group :test do | |
... | |
gem 'stackprof' | |
... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ls tmp | |
stackprof-api-v1-hogescontroller-get-show-capacity-over-returns-capacity-over.dump |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bundle exec stackprof tmp/stackprof-* | |
================================== | |
Mode: cpu(2000) | |
Samples: 606 (0.00% miss rate) | |
GC: 50 (8.25%) | |
================================== | |
TOTAL (pct) SAMPLES (pct) FRAME | |
552 (49.1%) 552 (49.1%) block in ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter#execute | |
88 (7.8%) 88 (7.8%) block in Logger::LogDevice#write | |
25 (2.2%) 21 (1.9%) ActiveSupport::HashWithIndifferentAccess#update | |
18 (1.6%) 18 (1.6%) ActiveSupport::HashWithIndifferentAccess#convert_value | |
16 (1.4%) 16 (1.4%) block (2 levels) in <class:Array> | |
18 (1.6%) 15 (1.3%) ActiveRecord::Type::DateTime#fallback_string_to_time | |
42 (3.7%) 14 (1.2%) block in ActiveSupport::Dependencies::Loadable#require | |
17 (1.5%) 12 (1.1%) ActiveSupport::TimeZone#parse | |
15 (1.3%) 10 (0.9%) ActiveRecord::LazyAttributeHash#assign_default_value | |
10 (0.9%) 10 (0.9%) Arel::Collectors::Bind#<< | |
62 (5.5%) 9 (0.8%) ActiveRecord::Attribute#value | |
32 (2.8%) 9 (0.8%) block in FactoryGirl::Evaluator.define_attribute | |
7 (0.6%) 7 (0.6%) ActiveRecord::Attribute#initialize | |
22 (2.0%) 7 (0.6%) ActiveRecord::LazyAttributeHash#[] | |
6 (0.5%) 6 (0.5%) block in <top (required)> | |
8 (0.7%) 6 (0.5%) ActiveSupport::TimeWithZone#localtime | |
24 (2.1%) 6 (0.5%) ActiveSupport::HashWithIndifferentAccess#[]= | |
6 (0.5%) 6 (0.5%) ActiveRecord::Type::TimeValue#fast_string_to_time | |
49 (4.4%) 5 (0.4%) ActiveRecord::AttributeMethods::Dirty#store_original_raw_attribute | |
5 (0.4%) 5 (0.4%) ActiveSupport::Logger::SimpleFormatter#call | |
5 (0.4%) 5 (0.4%) ThreadSafe::NonConcurrentCacheBackend#[] | |
5 (0.4%) 5 (0.4%) ActiveRecord::ConnectionAdapters::Mysql2Adapter#each_hash | |
4 (0.4%) 4 (0.4%) block in ActiveSupport::Dependencies#search_for_file | |
4 (0.4%) 4 (0.4%) block in ActiveSupport::HashWithIndifferentAccess#update | |
147 (13.1%) 4 (0.4%) ActiveRecord::AttributeMethods::Dirty#write_attribute | |
4 (0.4%) 4 (0.4%) LolipopAccount#setup_date | |
4 (0.4%) 4 (0.4%) ActiveRecord::Associations#association_instance_get | |
7 (0.6%) 4 (0.4%) FactoryGirl::AttributeList#each | |
607 (54.0%) 4 (0.4%) ActiveSupport::Callbacks#run_callbacks | |
4 (0.4%) 4 (0.4%) block in Arel::InsertManager#insert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEST=stackprof INTERVAL=2000 be rspec spec/controllers/api/v1/account_relocations_controller_spec.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec.configure do |config| | |
... | |
config.around(:each) do |example| | |
dest = ENV.fetch('DEST', 'stackprof-test-') | |
path = Rails.root.join("tmp/#{dest}-#{example.full_description.parameterize}.dump") | |
interval = ENV.fetch('INTERVAL', 1000).to_i | |
StackProf.run(mode: :cpu, out: path.to_s, interval: interval) do | |
example.run | |
end | |
end | |
... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment