memprof2 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d9b55a50f67161cea84ebdc89645374630660569
4
- data.tar.gz: 35e0293167a9dfe44204fc2a13bf0422db6181cb
2
+ SHA256:
3
+ metadata.gz: c9ce828abc8d8a17b915fee8fa2ab9cbc146e94b60266110440c5b2be6ea5002
4
+ data.tar.gz: 4b27bd87a42decfcf2a0c09ec650e266a6c23f5ca2cb49a14dc135e41c807850
5
5
  SHA512:
6
- metadata.gz: 596133c5b056bff18425149e7562a169087341e4a785c0f888f40f50a3b7984fb90da034c75995cd4acbb9627eb976b207c9a14234db4b85cedc9ae1ffb04dd8
7
- data.tar.gz: d303b970902c1d2eb53b8f8bf5612a0af967d2d2a7a9a9ae878f004dce7598a0cb471b6b088887ce2471d277eb2eb538d03122370d73b84ed0c81e1cbd3ea496
6
+ metadata.gz: 45454dcdf9079e9c1fc66f3da0b4fdde5f86741930dc415c05975030738a5c9c532e380475c4d15ff4b34a69cdcea1e07c6304b41711e8023ec851da1cf830cc
7
+ data.tar.gz: 5b5978fadb7f0293ace9ec32435ee6fe4ba753a522f636d5083503269e75f6dfc5b17e65ca9ea89fe0422f8617a10725946a57023571632cf55861ef03297107
@@ -1,3 +1,9 @@
1
+ # 0.1.2 (2018/10/05)
2
+
3
+ Enhancements:
4
+
5
+ * Add `Memprof2.run_with_report` (thanks to @takkanm)
6
+
1
7
  # 0.1.1 (2015/10/10)
2
8
 
3
9
  Changes
data/README.md CHANGED
@@ -68,9 +68,19 @@ After `GC.start`, only the very last instance of `"abc"` will still exist:
68
68
 
69
69
  *Note*: Use `Memprof2.report!` to clear out tracking data after printing out results.
70
70
 
71
+ Use `trace` and `ignore` options to restrict files to report. You can write patterns by regular expressions:
72
+
73
+ ```
74
+ Memprof2.start
75
+ 10.times{ $last_str = "abc" }
76
+ GC.start
77
+ Memprof2.report!(trace: /file\.rb/, ignore: /ignore_me/, out: "/path/to/file")
78
+ Memprof2.stop
79
+ ```
80
+
71
81
  ## Memprof2.run
72
82
 
73
- Simple wrapper for `Memprof2.start/stop` that will start/stop memprof around a given block of ruby code.
83
+ A shorthand for `Memprof2.start/stop` that will start/stop memprof around a given block of ruby code.
74
84
 
75
85
  ```ruby
76
86
  Memprof2.run do
@@ -91,6 +101,20 @@ For the block of ruby code, print out file:line:class pairs for ruby objects cre
91
101
 
92
102
  *Note*: You can call GC.start at the end of the block to print out only objects that are 'leaking' (i.e. objects that still have inbound references).
93
103
 
104
+ ## Memprof2.run_with_report
105
+
106
+ A shorthand for `Memprof2.start/report/stop`.
107
+
108
+ Following codes work exactly same with the above example.
109
+
110
+ ```ruby
111
+ Memprof2.run_with_report(out: "/path/to/file") do
112
+ 100.times{ "abc" }
113
+ 100.times{ 1.23 + 1 }
114
+ 100.times{ Module.new }
115
+ end
116
+ ```
117
+
94
118
  ## ChangeLog
95
119
 
96
120
  See [CHANGELOG.md](CHANGELOG.md) for details.
data/example.rb CHANGED
@@ -27,3 +27,10 @@ Memprof2.run do
27
27
  100.times{ Module.new }
28
28
  Memprof2.report(out: "example.out")
29
29
  end
30
+
31
+ ############
32
+ Memprof2.run_with_report(out: "example.out") do
33
+ 100.times{ "abc" }
34
+ 100.times{ 1.23 + 1 }
35
+ 100.times{ Module.new }
36
+ end
@@ -26,6 +26,14 @@ class Memprof2
26
26
  report(opts)
27
27
  ObjectSpace.trace_object_allocations_clear
28
28
  end
29
+
30
+ def run_with_report(opts = {}, &block)
31
+ start
32
+ yield
33
+ report(opts)
34
+ ensure
35
+ stop
36
+ end
29
37
  end
30
38
 
31
39
  def report(opts={})
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "memprof2"
3
- spec.version = "0.1.1"
3
+ spec.version = "0.1.2"
4
4
  spec.authors = ["Naotoshi Seo"]
5
5
  spec.email = ["sonots@gmail.com"]
6
6
  spec.description = %q{Ruby memory profiler for >= Ruby 2.1.0}
@@ -50,4 +50,12 @@ class TestMemprof2 < Test::Unit::TestCase
50
50
  assert_match("test/test_memprof2.rb:46:String\n", File.read(opts_bang[:out]))
51
51
  assert_match("", File.read(opts[:out]))
52
52
  end
53
+
54
+ def test_run_with_result
55
+ opts = {out: "tmp/test_run_with_report.out"}
56
+ Memprof2.run_with_report(opts) do
57
+ a = "abc"
58
+ end
59
+ assert_match("test/test_memprof2.rb:57:String\n", File.read(opts[:out]))
60
+ end
53
61
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memprof2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-09 00:00:00.000000000 Z
11
+ date: 2018-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  version: '0'
79
79
  requirements: []
80
80
  rubyforge_project:
81
- rubygems_version: 2.4.5
81
+ rubygems_version: 2.7.6
82
82
  signing_key:
83
83
  specification_version: 4
84
84
  summary: Ruby memory profiler for >= Ruby 2.1.0