* test/profile_test_all.rb: added.
You can use test-all profiler with the following command: RUBY_TEST_ALL_PROFILE=true make test-all This command generates ./test_all_profile and you can analyse which tests consume memories. * test/runner.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f85b841a01
commit
32623a1627
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
Fri Oct 29 23:32:36 2010 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* test/profile_test_all.rb: added.
|
||||||
|
You can use test-all profiler with the following command:
|
||||||
|
RUBY_TEST_ALL_PROFILE=true make test-all
|
||||||
|
This command generates ./test_all_profile and you can analyse
|
||||||
|
which tests consume memories.
|
||||||
|
|
||||||
|
* test/runner.rb: ditto.
|
||||||
|
|
||||||
Fri Oct 29 10:02:03 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
Fri Oct 29 10:02:03 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* tool/enc-unicode.rb,
|
* tool/enc-unicode.rb,
|
||||||
|
52
test/profile_test_all.rb
Normal file
52
test/profile_test_all.rb
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
require 'objspace'
|
||||||
|
|
||||||
|
#
|
||||||
|
# purpose:
|
||||||
|
# Profile memory usage of each tests.
|
||||||
|
#
|
||||||
|
# usage:
|
||||||
|
# RUBY_TEST_ALL_PROFILE=true make test-all
|
||||||
|
#
|
||||||
|
# output:
|
||||||
|
# ./test_all_profile
|
||||||
|
#
|
||||||
|
# collected information:
|
||||||
|
# - ObjectSpace.memsize_of_all
|
||||||
|
# - GC.stat
|
||||||
|
# - /proc/self/statm (if it exists)
|
||||||
|
#
|
||||||
|
|
||||||
|
class MiniTest::Unit::TestCase
|
||||||
|
alias orig_run run
|
||||||
|
|
||||||
|
$test_all_profile_out = open('test_all_profile', 'w')
|
||||||
|
$test_all_profile_gc_stat_hash = {}
|
||||||
|
|
||||||
|
if FileTest.exist?('/proc/self/statm')
|
||||||
|
# for Linux (only?)
|
||||||
|
$test_all_profile_out.puts "name\tmemsize_of_all\t" +
|
||||||
|
(GC.stat.keys +
|
||||||
|
%w(size resident share text lib data dt)).join("\t")
|
||||||
|
|
||||||
|
def memprofile_test_all_result_result
|
||||||
|
"#{self.class}\##{self.__name__}\t" \
|
||||||
|
"#{ObjectSpace.memsize_of_all}\t" \
|
||||||
|
"#{GC.stat($test_all_profile_gc_stat_hash).values.join("\t")}\t" \
|
||||||
|
"#{File.read('/proc/self/statm').split(/\s+/).join("\t")}"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
$test_all_profile_out.puts "name\tmemsize_of_alls\t" + GC.stat.keys.join("\t")
|
||||||
|
def memprofile_test_all_result_result
|
||||||
|
"#{self.class}\##{self.__name__}\t" \
|
||||||
|
"#{ObjectSpace.memsize_of_all}\t" \
|
||||||
|
"#{GC.stat($test_all_profile_gc_stat_hash).values.join("\t")}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def run runner
|
||||||
|
result = orig_run(runner)
|
||||||
|
$test_all_profile_out.puts memprofile_test_all_result_result
|
||||||
|
$test_all_profile_out.flush
|
||||||
|
result
|
||||||
|
end
|
||||||
|
end
|
@ -6,6 +6,8 @@ require 'test/unit'
|
|||||||
src_testdir = File.dirname(File.expand_path(__FILE__))
|
src_testdir = File.dirname(File.expand_path(__FILE__))
|
||||||
srcdir = File.dirname(src_testdir)
|
srcdir = File.dirname(src_testdir)
|
||||||
|
|
||||||
|
require_relative 'profile_test_all' if ENV['RUBY_TEST_ALL_PROFILE'] == 'true'
|
||||||
|
|
||||||
tests = Test::Unit.new {|files, options|
|
tests = Test::Unit.new {|files, options|
|
||||||
options[:base_directory] = src_testdir
|
options[:base_directory] = src_testdir
|
||||||
if files.empty?
|
if files.empty?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user