Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Tweaks to GC.stat and related excludes.

  • Loading branch information...
commit f35397a2dbe23c7e1ab8f651c38d0e608103be3a 1 parent 017d9b4
@headius headius authored
Showing with 33 additions and 19 deletions.
  1. +31 −16 src/jruby/kernel19/gc.rb
  2. +2 −3 test/externals/ruby1.9/excludes/TestGc.rb
View
47 src/jruby/kernel19/gc.rb
@@ -1,5 +1,5 @@
module GC
- def self.stat
+ def self.stat(all_stats = {})
require 'java'
gc_beans = java.lang.management.ManagementFactory.garbage_collector_mx_beans
pool_beans = {}
@@ -7,12 +7,27 @@ def self.stat
pool_beans[pool_bean.name] = pool_bean
end
- all_stats = {}
+ all_stats.merge!({
+ :count => 0,
+ :time => 0,
+ :committed => 0.0,
+ :init => 0.0,
+ :max => 0.0,
+ :used => 0.0,
+ :peak_committed => 0.0,
+ :peak_init => 0.0,
+ :peak_max => 0.0,
+ :peak_used => 0.0,
+ :last_committed => 0.0,
+ :last_init => 0.0,
+ :last_max => 0.0,
+ :last_used => 0.0
+ })
gc_beans.each do |gc_bean|
gc_stats = all_stats[gc_bean.name] = {}
- gc_stats[:count] = gc_bean.collection_count
- gc_stats[:time] = gc_bean.collection_time
+ all_stats[:count] += gc_stats[:count] = gc_bean.collection_count
+ all_stats[:time] += gc_stats[:time] = gc_bean.collection_time
gc_bean.memory_pool_names.each do |pool_name|
pool_bean = pool_beans[pool_name]
@@ -24,18 +39,18 @@ def self.stat
peak_usage = pool_bean.peak_usage
last_usage = pool_bean.collection_usage
- pool_stats[:committed] = usage.committed
- pool_stats[:init] = usage.init
- pool_stats[:max] = usage.max
- pool_stats[:used] = usage.used
- pool_stats[:peak_committed] = peak_usage.committed
- pool_stats[:peak_init] = peak_usage.init
- pool_stats[:peak_max] = peak_usage.max
- pool_stats[:peak_used] = peak_usage.used
- pool_stats[:last_committed] = last_usage.committed
- pool_stats[:last_init] = last_usage.init
- pool_stats[:last_max] = last_usage.max
- pool_stats[:last_used] = last_usage.used
+ all_stats[:committed] += pool_stats[:committed] = usage.committed
+ all_stats[:init] += pool_stats[:init] = usage.init
+ all_stats[:max] += pool_stats[:max] = usage.max
+ all_stats[:used] += pool_stats[:used] = usage.used
+ all_stats[:peak_committed] += pool_stats[:peak_committed] = peak_usage.committed
+ all_stats[:peak_init] += pool_stats[:peak_init] = peak_usage.init
+ all_stats[:peak_max] += pool_stats[:peak_max] = peak_usage.max
+ all_stats[:peak_used] += pool_stats[:peak_used] = peak_usage.used
+ all_stats[:last_committed] += pool_stats[:last_committed] = last_usage.committed
+ all_stats[:last_init] += pool_stats[:last_init] = last_usage.init
+ all_stats[:last_max] += pool_stats[:last_max] = last_usage.max
+ all_stats[:last_used] += pool_stats[:last_used] = last_usage.used
end
end
View
5 test/externals/ruby1.9/excludes/TestGc.rb
@@ -1,3 +1,2 @@
-exclude :test_count, "needs investigation"
-exclude :test_gc_parameter, "needs investigation"
-exclude :test_stat, "needs investigation"
+exclude :test_count, "expects GC.start to force GC run"
+exclude :test_gc_parameter, "MRI-specific"
Please sign in to comment.
Something went wrong with that request. Please try again.