README.md in memory_profiler-0.9.0 vs README.md in memory_profiler-0.9.1

- old
+ new

@@ -1,11 +1,15 @@ # MemoryProfiler -A memory profiler for Ruby 2.1.0 +A memory profiler for Ruby [![Build Status](https://travis-ci.org/SamSaffron/memory_profiler.png?branch=master)](https://travis-ci.org/SamSaffron/memory_profiler) +## Requirements + +Ruby(MRI) Version 2.1.0 and above. + ## Installation Add this line to your application's Gemfile: gem 'memory_profiler' @@ -27,12 +31,64 @@ end report.pretty_print ``` -Example Session: +## Options +You can use `allow_files` option for displaying only lines which contain string or array with strings: + +``` +pry> require 'memory_profiler' +pry> MemoryProfiler.report(allow_files: 'rubygems'){ require 'mime-types' }.pretty_print +Total allocated 82375 +Total retained 22618 + +allocated memory by gem +----------------------------------- +rubygems x 305879 + +allocated memory by file +----------------------------------- +/home/sam/.rbenv/versions/2.1.0-github/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb x 285433 +/home/sam/.rbenv/versions/2.1.0-github/lib/ruby/2.1.0/rubygems/basic_specification.rb x 18597 +/home/sam/.rbenv/versions/2.1.0-github/lib/ruby/2.1.0/rubygems.rb x 2218 +/home/sam/.rbenv/versions/2.1.0-github/lib/ruby/2.1.0/rubygems/specification.rb x 1169 +/home/sam/.rbenv/versions/2.1.0-github/lib/ruby/2.1.0/rubygems/defaults.rb x 520 +/home/sam/.rbenv/versions/2.1.0-github/lib/ruby/2.1.0/rubygems/core_ext/kernel_gem.rb x 80 +/home/sam/.rbenv/versions/2.1.0-github/lib/ruby/2.1.0/rubygems/version.rb x 80 + +. . . +``` + +Also you can print report to file. For this use `pretty_print` method with `to_file` option and `path_to_your_log_file` string: +``` +$ pry +pry> require 'memory_profiler' +pry> MemoryProfiler.report(allow_files: 'rubygems'){ require 'mime-types' }.pretty_print(to_file: 'path_to_your_log_file') + +$ less my_report.txt +Total allocated 82375 +Total retained 22618 + +allocated memory by gem +----------------------------------- +rubygems x 305879 + +. . . +``` + +Other options include: + +* `top`: maximum number of entries to display in a report +* `trace`: an array of classes for which you explicitly want to trace object allocations +* `ignore_files`: a regular expression used to exclude certain files from tracing (opposite of `allow_files`) + +Check out `Reporter#new` for more details. + +## Example Session + You can easily use memory_profiler to profile require impact of a gem, for example: ``` pry> require 'memory_profiler' @@ -314,10 +370,10 @@ - This is quite stable, upping version to reflect - Fixed bug where it would crash when location was nil for some reason ### 0.0.4 -- Added compatability with released version of Ruby 2.1.0 +- Added compatibility with released version of Ruby 2.1.0 - Cleanup to use latest APIs available in 2.1.0 ### 0.0.3 - Added string analysis