Skip to content

Commit 588a165

Browse files
committed
Add AllocationTracer for create action.
1 parent f6d58a7 commit 588a165

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require 'test_helper'
2+
require 'objspace'
3+
4+
class DocumentsIntegrationTest < ActionDispatch::IntegrationTest
5+
test "create" do
6+
post '/documents', params: { document: { title: "New things", content: "Doing them" } }
7+
8+
document = Document.last
9+
assert_equal 'New things', document.title
10+
assert_equal 'Doing them', document.content
11+
end
12+
end
13+
14+
ObjectSpace.trace_object_allocations do
15+
3000.times do
16+
Minitest.run_one_method(DocumentsIntegrationTest, 'test_create')
17+
end
18+
end
19+
20+
__END__
21+
ObjectSpace::AllocationTracer.setup(%i{path line type})
22+
result = ObjectSpace::AllocationTracer.trace do
23+
3000.times do
24+
Minitest.run_one_method(DocumentsIntegrationTest, 'test_create')
25+
end
26+
end
27+
result.sort_by { |info, counts| counts.first }.reverse.first(5).each do |r|
28+
p r
29+
end

0 commit comments

Comments
 (0)