lib/pilfer/profile.rb in pilfer-0.0.1.pre3 vs lib/pilfer/profile.rb in pilfer-0.0.1.pre4

- old
+ new

@@ -7,23 +7,22 @@ @data = data @start = start end def each(&block) - files.each(&block) + files.to_a.sort_by(&:first).each(&block) end def files - data.each_with_object({}) do |(file, lines), files| - profile_lines = lines[1..-1]. - each_with_index. - each_with_object({}) do |(data, number), lines| + data.inject({}) do |files, (file, lines)| + profile_lines = {} + lines[1..-1].each_with_index do |data, number| next unless data.any? {|datum| datum > 0 } wall_time, cpu_time, calls = data - lines[number] = { 'wall_time' => wall_time, - 'cpu_time' => cpu_time, - 'calls' => calls } + profile_lines[number] = { 'wall_time' => wall_time, + 'cpu_time' => cpu_time, + 'calls' => calls } end total_wall, child_wall, exclusive_wall, total_cpu, child_cpu, exclusive_cpu = lines[0] @@ -31,9 +30,10 @@ cpu = total_cpu files[file] = { 'wall_time' => wall, 'cpu_time' => cpu, 'lines' => profile_lines } + files end end end end