【求助】谁来帮我看下这个是什么语言
#!/usr/local/bin/rubyrequire 'yaml'
require 'thread'
#require 'mmap'
full_path = $0
if full_path !~ /^\//
full_path = Dir.getwd + '/' + $0
end
base_path = full_path[0..(full_path =~ /\/(bin|lib)\//)]
$: << "#{base_path}lib/mpd" << "#{base_path}lib/slx" << "#{base_path}lib/all"
puts "#{full_path} #{base_path}"
require 'forked_test_gui'
class MemoryProfiler
DEFAULTS = {:delay => 10, :string_debug => false}
def self.start(opt={})
opt = DEFAULTS.dup.merge(opt)
Thread.new do
prev = Hash.new(0)
curr = Hash.new(0)
curr_strings = []
delta = Hash.new(0)
file = File.open("/home/ltrx/memory_profiler.log.#{Time.now}",'w')
loop do
begin
GC.start
curr.clear
curr_strings = [] if opt[:string_debug]
ObjectSpace.each_object do |o|
curr[o.class] += 1 #Marshal.dump(o).size rescue 1
if opt[:string_debug] and o.class == String
curr_strings.push o
end
end
if opt[:string_debug]
File.open("/home/ltrx/memory_profiler_strings.log.#{Time.now.to_i}",'w') do |f|
curr_strings.sort.each do |s|
f.puts s
end
end
curr_strings.clear
end
delta.clear
(curr.keys + delta.keys).uniq.each do |k,v|
delta[k] = curr[k]-prev[k]
end
file.puts "Top 20"
delta.sort_by { |k,v| -v.abs }[0..19].sort_by { |k,v| -v}.each do |k,v|
file.printf "%+5d: %s (%d)\n", v, k.name, curr[k] unless v == 0
end
file.flush
delta.clear
prev.clear
prev.update curr
GC.start
rescue Exception => err
STDERR.puts "** memory_profiler error: #{err}"
end
sleep opt[:delay]
end
end
end
end