memory_profiler 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e06600592ba32b7ac0b1184619e2c5f5f121af8
4
- data.tar.gz: 15408fc5c3da8f1d71c5e156f41d84d34e269fb2
3
+ metadata.gz: 137993daf571e91e9226e91bfac2f5fc8de00e24
4
+ data.tar.gz: dd960b34c925167e99d3f99f9e16729210fbd511
5
5
  SHA512:
6
- metadata.gz: cb7fd523c0abf056c31fdfaae902a35ebf04122fd422fb21d339afe3a7513fb34f712e8ed7c4422ffa00313aeb037656adde9f62885cfb8574367ea949ad2cc8
7
- data.tar.gz: c592a9668fbd024dd176fcebab3938b031efdd09ee42c6840ce61f1a0a5fd0dd0e0f60c3cdaeff4f9119121594ad95daa5eb821f4eb0a7eeeeba09d7e0b51ee6
6
+ metadata.gz: fe442012610dc38045c586f7a732bfdde5b60471a98196a836d3cd9730f48b5d52ef6f4b6bb493aa4f98de2e64f8773b61093e85355b4d90ae37915dd0c4d8a5
7
+ data.tar.gz: 778ff7260499849b6580e6c8a0c4864507af34d7417ad3bcf7c09b9b071ddf2ab45156e6a6c1caf74b61d40d7fd3b81d63013030a53236c9dc7c95d4ede8b7c9
@@ -60,29 +60,29 @@ module MemoryProfiler
60
60
  self
61
61
  end
62
62
 
63
- def pretty_print
64
- puts "Total allocated #{total_allocated}"
65
- puts "Total retained #{total_retained}"
66
- puts
63
+ def pretty_print(io = STDOUT)
64
+ io.puts "Total allocated #{total_allocated}"
65
+ io.puts "Total retained #{total_retained}"
66
+ io.puts
67
67
  ["allocated","retained"]
68
68
  .product(["memory", "objects"])
69
69
  .product(["gem", "file", "location"])
70
70
  .each do |(type, metric), name|
71
- dump "#{type} #{metric} by #{name}", self.send("#{type}_#{metric}_by_#{name}")
71
+ dump "#{type} #{metric} by #{name}", self.send("#{type}_#{metric}_by_#{name}"), io
72
72
  end
73
73
  end
74
74
 
75
- def dump(description, data)
76
- puts description
77
- puts "-----------------------------------"
75
+ def dump(description, data, io)
76
+ io.puts description
77
+ io.puts "-----------------------------------"
78
78
  if data
79
79
  data.each do |item|
80
- puts "#{item[:data]} x #{item[:count]}"
80
+ io.puts "#{item[:data]} x #{item[:count]}"
81
81
  end
82
82
  else
83
- puts "NO DATA"
83
+ io.puts "NO DATA"
84
84
  end
85
- puts
85
+ io.puts
86
86
  end
87
87
  end
88
88
  end
@@ -45,7 +45,9 @@ module MemoryProfiler
45
45
  count += (current_count || 1) unless row.nil?
46
46
  end
47
47
 
48
- found.reverse
48
+ found
49
+ .sort!{|x,y| x[:count] <=> y[:count] }
50
+ .reverse
49
51
  end
50
52
  end
51
53
  end
@@ -1,3 +1,3 @@
1
1
  module MemoryProfiler
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/test/test_results.rb CHANGED
@@ -2,6 +2,7 @@ require 'test_helper'
2
2
 
3
3
  class TestResults < Minitest::Test
4
4
  def test_pretty_print_works
5
- MemoryProfiler::Results.new.pretty_print
5
+ io = StringIO.new
6
+ MemoryProfiler::Results.new.pretty_print io
6
7
  end
7
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memory_profiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-09 00:00:00.000000000 Z
11
+ date: 2013-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  version: '0'
129
129
  requirements: []
130
130
  rubyforge_project:
131
- rubygems_version: 2.1.0.rc.2
131
+ rubygems_version: 2.0.7
132
132
  signing_key:
133
133
  specification_version: 4
134
134
  summary: Memory profiling routines for Ruby Head