Skip to content

Commit 1e591dc

Browse files
committed
Add wall time for stackprof tests
1 parent 3a0bc8e commit 1e591dc

File tree

3 files changed

+59
-13
lines changed

3 files changed

+59
-13
lines changed

test/controllers/documents_controller_test.rb

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,19 @@ 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
26+
# ruby -I lib:test test/controllers/documents_controller_test.rb -n test_index_sp_cpu
27+
test "index sp cpu" do
28+
StackProf.run(mode: :cpu, out: 'graphs/rails_only/index_controller_stackprof_cpu.dump') do
29+
3000.times do
30+
get :index
31+
assert_equal 200, response.status
32+
end
33+
end
34+
end
35+
36+
# ruby -I lib:test test/controllers/documents_controller_test.rb -n test_index_sp_wall
37+
test "index sp wall" do
38+
StackProf.run(mode: :wall, out: 'graphs/rails_only/index_controller_stackprof_wall.dump') do
2939
3000.times do
3040
get :index
3141
assert_equal 200, response.status
@@ -68,9 +78,9 @@ class DocumentsControllerTest < ActionController::TestCase
6878
end
6979
end
7080

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
81+
# ruby -I lib:test test/controllers/documents_controller_test.rb -n test_create_sp_cpu
82+
test "create sp cpu" do
83+
StackProf.run(mode: :cpu, out: 'graphs/rails_only/create_controller_stackprof_cpu.dump') do
7484
3000.times do
7585
post :create, document: { title: "New things", content: "Doing them" }
7686

@@ -81,6 +91,18 @@ class DocumentsControllerTest < ActionController::TestCase
8191
end
8292
end
8393

94+
# ruby -I lib:test test/controllers/documents_controller_test.rb -n test_create_sp_wall
95+
test "create sp wall" do
96+
StackProf.run(mode: :wall, out: 'graphs/rails_only/create_controller_stackprof_wall.dump') do
97+
3000.times do
98+
post :create, document: { title: "New things", content: "Doing them" }
99+
100+
document = Document.last
101+
assert_equal 'New things', document.title
102+
assert_equal 'Doing them', document.content
103+
end
104+
end
105+
end
84106
# ruby -I lib:test test/controllers/documents_controller_test.rb -n test_create_flame
85107
test "create flame" do
86108
Flamegraph.generate("graphs/rails_only/create_controller_flamegraph.html") do

test/integration/documents_integration_test.rb

Lines changed: 30 additions & 6 deletions
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_path
13+
get '/documents'
1414
assert_equal 200, response.status
1515
end
1616
File.open('graphs/rails_only/index_integration_callstack.html', 'w') do |file|
@@ -22,9 +22,19 @@ 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
25+
# ruby -I lib:test test/integration/documents_integration_test.rb -n test_index_sp_cpu
26+
test "index sp cpu" do
27+
StackProf.run(mode: :cpu, out: 'graphs/rails_only/index_integration_stackprof_cpu.dump') do
28+
3000.times do
29+
get '/documents'
30+
assert_equal 200, response.status
31+
end
32+
end
33+
end
34+
35+
# ruby -I lib:test test/integration/documents_integration_test.rb -n test_index_sp_wall
36+
test "index sp wall" do
37+
StackProf.run(mode: :wall, out: 'graphs/rails_only/index_integration_stackprof_wall.dump') do
2838
3000.times do
2939
get '/documents'
3040
assert_equal 200, response.status
@@ -67,9 +77,9 @@ class DocumentsIntegrationTest < ActionDispatch::IntegrationTest
6777
end
6878
end
6979

70-
# ruby -I lib:test test/integration/documents_integration_test.rb -n test_create_sp
80+
# ruby -I lib:test test/integration/documents_integration_test.rb -n test_create_sp_cpu
7181
test "create sp" do
72-
StackProf.run(mode: :cpu, out: 'graphs/rails_only/create_integration_stackprof.dump') do
82+
StackProf.run(mode: :cpu, out: 'graphs/rails_only/create_integration_stackprof_cpu.dump') do
7383
3000.times do
7484
post '/documents', document: { title: "New things", content: "Doing them" }
7585

@@ -79,6 +89,20 @@ class DocumentsIntegrationTest < ActionDispatch::IntegrationTest
7989
end
8090
end
8191
end
92+
93+
# ruby -I lib:test test/integration/documents_integration_test.rb -n test_create_sp_wall
94+
test "create sp wall" do
95+
StackProf.run(mode: :wall, out: 'graphs/rails_only/create_integration_stackprof_wall.dump') do
96+
3000.times do
97+
post '/documents', document: { title: "New things", content: "Doing them" }
98+
99+
document = Document.last
100+
assert_equal 'New things', document.title
101+
assert_equal 'Doing them', document.content
102+
end
103+
end
104+
end
105+
82106
# ruby -I lib:test test/integration/documents_integration_test.rb -n test_create_flame
83107
test "create flame" do
84108
Flamegraph.generate("graphs/rails_only/create_integration_flamegraph.html") do

test/integration/documents_stackprof_index_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class DocumentsIntegrationTest < ActionDispatch::IntegrationTest
1010
Minitest.run_one_method(DocumentsIntegrationTest, 'test_index')
1111

1212
# ruby -Ilib:test test/integration/documents_stackprof_index_test.rb
13-
StackProf.run(mode: :cpu, out: 'graphs/including_minitest/index_integration_stackprof.dump') do
13+
StackProf.run(mode: :wall, out: 'graphs/including_minitest/index_integration_stackprof.dump') do
1414
3000.times do
1515
Minitest.run_one_method(DocumentsIntegrationTest, 'test_index')
1616
end

0 commit comments

Comments
 (0)