rspec_memory_formatter 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/memory_formatter.rb +62 -0
- data/lib/rspec_memory_formatter.rb +1 -0
- data/lib/rspec_memory_formatter/version.rb +3 -0
- data/rspec_memory_formatter.gemspec +32 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MDUwOTZjOWMxZDAzNGMyMWVjMjhjZmRlMjQ4OTg4ZTEzZmJmNTU1YQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NDNlNGQ2Zjg3MzA2NzMzNmFhNzViYzc4MjIzZDI4ODdhYTg2Y2IzZQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NzgzYWQ5ZjE0NzQyMDRiOTRiNDVjODRlMzAzMDlhMmRkMTUwZWE4YjUwZmY3
|
10
|
+
NmI1ZWNmNmI0NDEyYzIwODJmMmYzZWI5ZTIwYzQ1YzBmMTY1N2RiZGVhOGM4
|
11
|
+
ODYxMGEzYmU1NTVlZDhlMTkyNTEzNDRiMjQyZTQ5OGExOTljNmE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZTg2NDgwYTgwMGJiNzU3ZGM5ZWU5Yzg0YWEzMTNkODZjYmUxMGJkY2E1Nzdj
|
14
|
+
OTA1NGU0NTIzOGRmMTcyN2MyZGVkMTI5OTdhZjU5MzU3ZWQwMWU0Y2JjYjI1
|
15
|
+
Mjc2NTM2Y2Q1NTQzNjM2MDI4MWM4MTljNDc3MjU4ODI3Njc5OWI=
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Daniel Vandersluis
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# RspecMemoryFormatter
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rspec_memory_formatter`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'rspec_memory_formatter'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install rspec_memory_formatter
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
rspec --format MemoryFormatter
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rspec_memory_formatter.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rspec_memory_formatter"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'rspec/core/formatters/progress_formatter'
|
2
|
+
require 'newrelic_rpm'
|
3
|
+
require 'active_support/core_ext/module/delegation'
|
4
|
+
|
5
|
+
class ProfileData < Hash
|
6
|
+
include Singleton
|
7
|
+
|
8
|
+
def sorted
|
9
|
+
self.class[sort_by{ |_, data| -(data[:end] - data[:start]) }]
|
10
|
+
end
|
11
|
+
|
12
|
+
def top(limit = 10)
|
13
|
+
self.class[sorted.first(limit)]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class MemoryFormatter < ::RSpec::Core::Formatters::BaseTextFormatter
|
18
|
+
def initialize(*)
|
19
|
+
super
|
20
|
+
@data = ProfileData.instance
|
21
|
+
end
|
22
|
+
|
23
|
+
def message(*)
|
24
|
+
# do nothing
|
25
|
+
end
|
26
|
+
|
27
|
+
def example_started(example)
|
28
|
+
path = example.metadata[:example_group][:file_path]
|
29
|
+
line = example.metadata[:line_number]
|
30
|
+
|
31
|
+
@data[example.object_id] = {
|
32
|
+
description: example.metadata.full_description,
|
33
|
+
path: "#{path}:#{line}",
|
34
|
+
start: NewRelic::Agent::Samplers::MemorySampler.new.sampler.get_sample
|
35
|
+
}
|
36
|
+
|
37
|
+
# super
|
38
|
+
end
|
39
|
+
|
40
|
+
def example_passed(example)
|
41
|
+
@data[example.object_id][:end] = NewRelic::Agent::Samplers::MemorySampler.new.sampler.get_sample
|
42
|
+
end
|
43
|
+
|
44
|
+
alias_method :example_failed, :example_passed
|
45
|
+
alias_method :example_pending, :example_passed
|
46
|
+
|
47
|
+
def dump_failures
|
48
|
+
top = @data.top
|
49
|
+
|
50
|
+
puts
|
51
|
+
puts "Top #{top.count} most memory consumed:"
|
52
|
+
|
53
|
+
top.values.each do |data|
|
54
|
+
puts " #{data[:description]}"
|
55
|
+
puts " #{color("%.3fMB" % [data[:end] - data[:start]], RSpec.configuration.failure_color)} #{data[:path]}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def dump_summary(*)
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'memory_formatter'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rspec_memory_formatter/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rspec_memory_formatter"
|
8
|
+
spec.version = RspecMemoryFormatter::VERSION
|
9
|
+
spec.authors = ["Daniel Vandersluis"]
|
10
|
+
spec.email = ["dvandersluis@selfmgmt.com"]
|
11
|
+
|
12
|
+
spec.summary = "RSpec 2 Formatter for showing memory stats"
|
13
|
+
spec.homepage = "https://github.com/dvandersluis/rspec_memory_formatter"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
17
|
+
# delete this section to allow pushing this gem to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec_memory_formatter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Vandersluis
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
type: :development
|
15
|
+
prerelease: false
|
16
|
+
name: bundler
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.11'
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
type: :development
|
29
|
+
prerelease: false
|
30
|
+
name: rake
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ~>
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '10.0'
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
type: :development
|
43
|
+
prerelease: false
|
44
|
+
name: rspec
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ~>
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '3.0'
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- dvandersluis@selfmgmt.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- .rspec
|
64
|
+
- .travis.yml
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- lib/memory_formatter.rb
|
72
|
+
- lib/rspec_memory_formatter.rb
|
73
|
+
- lib/rspec_memory_formatter/version.rb
|
74
|
+
- rspec_memory_formatter.gemspec
|
75
|
+
homepage: https://github.com/dvandersluis/rspec_memory_formatter
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata:
|
79
|
+
allowed_push_host: ! 'TODO: Set to ''http://mygemserver.com'''
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.1.5
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: RSpec 2 Formatter for showing memory stats
|
100
|
+
test_files: []
|
101
|
+
has_rdoc:
|