Sha256: 6c88d28b3bcfbc816fe732a0eef2b0f91a2b79907074023f7a1c23b49226b332
Contents?: true
Size: 927 Bytes
Versions: 1
Compression:
Stored size: 927 Bytes
Contents
module MemoryProfiler class Helpers def initialize @gem_guess_cache = Hash.new @location_cache = Hash.new { |h,k| h[k] = Hash.new.compare_by_identity } @class_name_cache = Hash.new.compare_by_identity @string_cache = Hash.new end def guess_gem(path) @gem_guess_cache[path] ||= if /(\/gems\/.*)*\/gems\/(?<gemname>[^\/]+)/ =~ path gemname elsif /\/rubygems[\.\/]/ =~ path "rubygems".freeze elsif /(?<app>[^\/]+\/(bin|app|lib))/ =~ path app else "other".freeze end end def lookup_location(file, line) @location_cache[file][line] ||= "#{file}:#{line}" end def lookup_class_name(klass) @class_name_cache[klass] ||= ((klass.is_a?(Class) && klass.name) || '<<Unknown>>').to_s end def lookup_string(obj) @string_cache[obj] ||= String.new << obj end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
memory_profiler-0.9.9 | lib/memory_profiler/helpers.rb |