Skip to content

Commit 0348b14

Browse files
committed
Add stackprof tests to main tests
1 parent d278095 commit 0348b14

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

test/controllers/documents_controller_test.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ class DocumentsControllerTest < ActionController::TestCase
2323
end
2424
end
2525

26+
# ruby -I lib:test test/controllers/documents_controller_test.rb -n test_index_sp
27+
test "index sp" do
28+
StackProf.run(mode: :cpu, out: 'graphs/rails_only/index_controller_stackprof.dump') do
29+
3000.times do
30+
get :index
31+
assert_equal 200, response.status
32+
end
33+
end
34+
end
35+
2636
# ruby -I lib:test test/controllers/documents_controller_test.rb -n test_index_flame
2737
test "index flame" do
2838
Flamegraph.generate("graphs/rails_only/index_controller_flamegraph.html") do
@@ -58,6 +68,19 @@ class DocumentsControllerTest < ActionController::TestCase
5868
end
5969
end
6070

71+
# ruby -I lib:test test/controllers/documents_controller_test.rb -n test_create_sp
72+
test "create sp" do
73+
StackProf.run(mode: :cpu, out: 'graphs/rails_only/create_controller_stackprof.dump') do
74+
3000.times do
75+
post :create, document: { title: "New things", content: "Doing them" }
76+
77+
document = Document.last
78+
assert_equal 'New things', document.title
79+
assert_equal 'Doing them', document.content
80+
end
81+
end
82+
end
83+
6184
# ruby -I lib:test test/controllers/documents_controller_test.rb -n test_create_flame
6285
test "create flame" do
6386
Flamegraph.generate("graphs/rails_only/create_controller_flamegraph.html") do

test/integration/documents_integration_test.rb

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class DocumentsIntegrationTest < ActionDispatch::IntegrationTest
1010
# ruby -I lib:test test/integration/documents_integration_test.rb -n test_index_rp
1111
test "index rp" do
1212
result = RubyProf.profile do
13-
get '/documents'
13+
get documents_path
1414
assert_equal 200, response.status
1515
end
1616
File.open('graphs/rails_only/index_integration_callstack.html', 'w') do |file|
@@ -22,6 +22,16 @@ class DocumentsIntegrationTest < ActionDispatch::IntegrationTest
2222
end
2323
end
2424

25+
# ruby -I lib:test test/integration/documents_integration_test.rb -n test_index_sp
26+
test "index sp" do
27+
StackProf.run(mode: :cpu, out: 'graphs/rails_only/index_integration_stackprof.dump') do
28+
3000.times do
29+
get '/documents'
30+
assert_equal 200, response.status
31+
end
32+
end
33+
end
34+
2535
# ruby -I lib:test test/integration/documents_integration_test.rb -n test_index_flame
2636
test "index flame" do
2737
Flamegraph.generate("graphs/rails_only/index_integration_flamegraph.html") do
@@ -57,6 +67,18 @@ class DocumentsIntegrationTest < ActionDispatch::IntegrationTest
5767
end
5868
end
5969

70+
# ruby -I lib:test test/integration/documents_integration_test.rb -n test_create_sp
71+
test "create sp" do
72+
StackProf.run(mode: :cpu, out: 'graphs/rails_only/create_integration_stackprof.dump') do
73+
3000.times do
74+
post '/documents', document: { title: "New things", content: "Doing them" }
75+
76+
document = Document.last
77+
assert_equal 'New things', document.title
78+
assert_equal 'Doing them', document.content
79+
end
80+
end
81+
end
6082
# ruby -I lib:test test/integration/documents_integration_test.rb -n test_create_flame
6183
test "create flame" do
6284
Flamegraph.generate("graphs/rails_only/create_integration_flamegraph.html") do

0 commit comments

Comments
 (0)