diff options
author | Jari Vetoniemi <jari.vetoniemi@indooratlas.com> | 2020-03-16 18:49:26 +0900 |
---|---|---|
committer | Jari Vetoniemi <jari.vetoniemi@indooratlas.com> | 2020-03-30 00:39:06 +0900 |
commit | fcbf63e62c627deae76c1b8cb8c0876c536ed811 (patch) | |
tree | 64cb17de3f41a2b6fef2368028fbd00349946994 /jni/ruby/lib/rubygems/resolver/stats.rb |
Fresh start
Diffstat (limited to 'jni/ruby/lib/rubygems/resolver/stats.rb')
-rw-r--r-- | jni/ruby/lib/rubygems/resolver/stats.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/jni/ruby/lib/rubygems/resolver/stats.rb b/jni/ruby/lib/rubygems/resolver/stats.rb new file mode 100644 index 0000000..c31e5be --- /dev/null +++ b/jni/ruby/lib/rubygems/resolver/stats.rb @@ -0,0 +1,44 @@ +class Gem::Resolver::Stats + def initialize + @max_depth = 0 + @max_requirements = 0 + @requirements = 0 + @backtracking = 0 + @iterations = 0 + end + + def record_depth(stack) + if stack.size > @max_depth + @max_depth = stack.size + end + end + + def record_requirements(reqs) + if reqs.size > @max_requirements + @max_requirements = reqs.size + end + end + + def requirement! + @requirements += 1 + end + + def backtracking! + @backtracking += 1 + end + + def iteration! + @iterations += 1 + end + + PATTERN = "%20s: %d\n" + + def display + $stdout.puts "=== Resolver Statistics ===" + $stdout.printf PATTERN, "Max Depth", @max_depth + $stdout.printf PATTERN, "Total Requirements", @requirements + $stdout.printf PATTERN, "Max Requirements", @max_requirements + $stdout.printf PATTERN, "Backtracking #", @backtracking + $stdout.printf PATTERN, "Iteration #", @iterations + end +end |