schwad_performance_logger 0.3.2 → 0.4.0

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
2
  SHA256:
3
- metadata.gz: dd6d203c9729e56ed7684650aa2fa88d9f20265f6d98db56eeff1d5a95aef1b1
4
- data.tar.gz: dfcbec9237c8928e7becf1bbf13c52d9955abade5fa11dc10ecec4dd8047e2bc
3
+ metadata.gz: ae71b883d6ce1e62e230e41a71b01c1f5b7c1e5e5c45992478c575e09a7dfb57
4
+ data.tar.gz: 5a16178772f46465ad4af1d938ed19f3950090026b1e2730c41ae1718828027e
5
5
  SHA512:
6
- metadata.gz: c7d454c9f5954b58c3326f1a60dac72a0d092a4b8e39b1a50160013f53cae011523ca53fe8591d49e702466c7b0d5683f3e2266426e6efa2b4900c40ca947ad2
7
- data.tar.gz: caa3f2a8fea167cef1fb66ff35c6ede2c7264853a5a7a1b4318983bb62536e55fc1a2736156c46a8975812e2781a9fb748d88e704584453e853771c7887bba93
6
+ metadata.gz: 3812e45de8ca0808bdfe89569a7091e7146ed387c9f661c1d2fd8e8f6cf76c2170ba1a625df9631c2927f18f947b16e8f62b1f8af74058dc404350ecafdb7861
7
+ data.tar.gz: a4ae0ada2de63085af0ba737dcd426f404b3b0c69032069d47058ea76f89bc49054eafacd26c969da1b6ddb1bd953065cd7598456204a9117300740da6bb8e7b
data/CODE_OF_CONDUCT.md CHANGED
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
55
55
  ## Enforcement
56
56
 
57
57
  Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at nick.schwaderer@oceanshq.com. All
58
+ reported by contacting the project team at nick.schwaderer@gmail.com. All
59
59
  complaints will be reviewed and investigated and will result in a response that
60
60
  is deemed necessary and appropriate to the circumstances. The project team is
61
61
  obligated to maintain confidentiality with regard to the reporter of an incident.
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018 Nick Schwaderer
3
+ Copyright (c) 2019 Nick Schwaderer
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # SchwadPerformanceLogger
2
2
 
3
3
  This gem allows you to track memory usage and time passage during the life of
4
- the SchwadPerformanceLogger object, as well as deltas between each check. The output
4
+ the SPL object, as well as deltas between each check. The output
5
5
  is `puts`'d to the console, and it also writes to a long-running CSV and per-object
6
6
  log file in `logs/schwad_performance_logger`
7
7
 
@@ -23,7 +23,7 @@ Or install it yourself as:
23
23
 
24
24
  ## Usage
25
25
 
26
- `pl = SchwadPerformanceLogger.new({full_memo: 'Check extract method refactoring'})`
26
+ `pl = SPL.new({full_memo: 'Check extract method refactoring'})`
27
27
 
28
28
  ```
29
29
  **********************************************************************
@@ -47,17 +47,17 @@ Starting Test memo. Current memory: 12(Mb), difference of 0 (mb) since beginning
47
47
 
48
48
  To disable any of the outputs:
49
49
 
50
- `SchwadPerformanceLogger.new({puts: false, log: false, csv: false})`
50
+ `SPL.new({puts: false, log: false, csv: false})`
51
51
 
52
52
  To have the logger 'pause' a number of seconds during the `puts` logging so that
53
53
  you can actually see the log as it goes by. This does not affect the 'time' measurement:
54
54
 
55
- `SchwadPerformanceLogger.new({pause: 8})`
55
+ `SPL.new({pause: 8})`
56
56
 
57
57
  ## Usage example:
58
58
 
59
59
  ```
60
- pl = SchwadPerformanceLogger.new({pause: 3, full_memo: 'Retry object-oriented approach.', log: false})
60
+ pl = SPL.new({pause: 3, full_memo: 'Retry object-oriented approach.', log: false})
61
61
  pl.log_performance('check status before writing to database')
62
62
 
63
63
  # code here
@@ -69,6 +69,135 @@ pl.log_performance('check status after writing to database')
69
69
  pl.log_performance('inspect final performance after executing service')
70
70
  ```
71
71
 
72
+ ## Further Profiling Tools
73
+
74
+ As well as logging memory and time throughout your code, SPL gives you easy access to frequently used popular profiling tools to inspect your code blocks.
75
+
76
+ ### IPS
77
+
78
+ Handy access to [Benchmark-ips](https://github.com/evanphx/benchmark-ips) measurements, just pass a block to ips:
79
+
80
+ ```ruby
81
+ SPL.ips do
82
+ ary = []
83
+ 35.times do
84
+ ary << (1..99).to_a.sample
85
+ end
86
+ end
87
+
88
+ #=> #<Benchmark::IPS::Report:0x00007fbc7f91df50 @entries=[#<Benchmark::IPS::Report::Entry:0x00007fbc7e0c3bd0 @label="PerformanceLogMethod", @microseconds=5002798.0, @iterations=34020, @stats=#<Benchmark::IPS::Stats::SD:0x00007fbc7e0c3c48 @mean=6805.780564500376, @error=195>, @measurement_cycle=630, @show_total_time=true>], @data=nil>
89
+ ```
90
+
91
+ ### Time
92
+
93
+ Same flow as above. Tired of writing out `start_time` and `Time.now - start_time` and also needing to 'puts' it out? Pass a block to `#time`. Runs ten times and spits out an average as well.
94
+
95
+ ```ruby
96
+ SPL.time do
97
+ ary = []
98
+ 35.times do
99
+ ary << (1..99).to_a.sample
100
+ end
101
+ end
102
+
103
+ #=> Average runtime 0.0002649 seconds. Max time 0.000508.seconds
104
+ ```
105
+
106
+ ### Allocate Count
107
+
108
+ Before, you would have to enable the `GC` before your code, use `ObjectSpace` to count objects before your code, then use it again after your code to compare allocated objects during your block of code. You'd also have to re-enable the `GC`! Gosh, that sure is a lot of work if you want to do this frequently. We make it simple.
109
+
110
+ ```ruby
111
+ SPL.allocate_count do
112
+ ary = []
113
+ 35.times do
114
+ ary << (1..99).to_a.sample
115
+ end
116
+ end
117
+
118
+ #=> {:FREE=>-121, :T_STRING=>50, :T_ARRAY=>36, :T_IMEMO=>35}
119
+ ```
120
+
121
+ ### Profile Memory
122
+
123
+ Gives you quick access to the amazing [memory_profiler](https://github.com/SamSaffron/memory_profiler) gem.
124
+
125
+ ```ruby
126
+ SPL.profile_memory do
127
+ ary = []
128
+ 35.times do
129
+ ary << (1..99).to_a.sample
130
+ end
131
+ end
132
+
133
+ # Total allocated: 37576 bytes (36 objects)
134
+ # Total retained: 0 bytes (0 objects)
135
+ #
136
+ # allocated memory by gem
137
+ # -----------------------------------
138
+ # 37576 other
139
+ #
140
+ # allocated memory by file
141
+ # -----------------------------------
142
+ # 37576 (irb)
143
+ #
144
+ # allocated memory by location
145
+ # -----------------------------------
146
+ # 37240 (irb):37
147
+ # 336 (irb):35
148
+ #
149
+ # allocated memory by class
150
+ # -----------------------------------
151
+ # 37576 Array
152
+ #
153
+ # allocated objects by gem
154
+ # -----------------------------------
155
+ # 36 other
156
+ #
157
+ # allocated objects by file
158
+ # -----------------------------------
159
+ # 36 (irb)
160
+ #
161
+ # allocated objects by location
162
+ # -----------------------------------
163
+ # 35 (irb):37
164
+ # 1 (irb):35
165
+ #
166
+ # allocated objects by class
167
+ # -----------------------------------
168
+ # 36 Array
169
+ ```
170
+
171
+ ### All Objects
172
+
173
+ Similarly, it's nice to get a rundown of all objects, in hash format, instead of goofing around with `ObjectSpace` manually we offer that up for you as well.
174
+
175
+ ```ruby
176
+ SPL.all_objects do
177
+ ary = []
178
+ 35.times do
179
+ ary << (1..99).to_a.sample
180
+ end
181
+ end
182
+
183
+ #=> [[Benchmark::IPS::Job, 1], [Rational, 1], [Benchmark::IPS::Report::Entry, 1], [Benchmark::IPS::Stats::SD, 1], [FFI::DynamicLibrary, 1], [DidYouMean::ClassNameChecker, 1], [Thread::Backtrace, 1], [NameError::message, 1], [NameError, 1], [#<Class:0x00007fbc7e816478>, 1], [Gem::Platform, 1], [IRB::Notifier::CompositeNotifier, 1], [IRB::Notifier::NoMsgNotifier, 1], [Enumerator, 1], [RubyToken::TkSPACE, 1], [FFI::Type::Mapped, 1], [IRB::ReadlineInputMethod, 1], [IRB::WorkSpace, 1], [IRB::Context, 1], [IRB::Irb, 1], [Gem::PathSupport, 1], [Monitor, 1], [IRB::Locale, 1], [DidYouMean::PlainFormatter, 1], [DidYouMean::DeprecatedIgnoredCallers, 1], [IRB::SLex, 1], [RubyLex, 1], [DidYouMean::ClassNameChecker::ClassName, 1], [URI::RFC2396_Parser, 1], [URI::RFC3986_Parser, 1], [Complex, 1], [ThreadGroup, 1], [IOError, 1], [Thread, 1], [RubyVM, 1], [NoMemoryError, 1], [SystemStackError, 1], [Random, 1], [ARGF.class, 1], [Benchmark::IPS::Job::Entry, 1], [Benchmark::IPS::Report, 1], [Benchmark::IPS::Job::StdoutReport, 1], [#<Class:0x00007fbc7e023e50>, 1], [FFI::Pointer, 1], [FFI::FunctionType, 2], [Integer, 2], [IRB::StdioOutputMethod, 2], [Binding, 2], [RubyToken::TkDOT, 2], [RubyToken::TkIDENTIFIER, 2], [FFI::StructLayout, 2], [UnboundMethod, 2], [RubyToken::TkEND, 2], [FFI::DynamicLibrary::Symbol, 2], [FFI::Function, 2], [fatal, 2], [RubyToken::TkNL, 3], [Thread::Mutex, 3], [IRB::Notifier::LeveledNotifier, 3], [IO, 5], [IRB::Inspector, 5], [BigDecimal, 6], [Float, 6], [FFI::StructLayout::Number, 7], [Object, 9], [Range, 17], [FFI::Type::Builtin, 21], [MatchData, 27], [Gem::Specification, 30], [Time, 31], [Module, 71], [IRB::SLex::Node, 78], [Gem::Dependency, 89], [Proc, 91], [Encoding, 101], [Symbol, 127], [Gem::Requirement, 159], [Hash, 188], [Gem::Version, 209], [Gem::StubSpecification, 252], [Gem::StubSpecification::StubLine, 252], [Regexp, 279], [Class, 633], [Array, 1838], [String, 15818]]
184
+ ```
185
+
186
+ ### Objects by Size
187
+
188
+ You can break down your objects by size as well, useful for debugging.
189
+
190
+ ```ruby
191
+ SPL.objects_by_size do
192
+ ary = []
193
+ 35.times do
194
+ ary << (1..99).to_a.sample
195
+ end
196
+ end
197
+
198
+ #=> {:T_OBJECT=>101848, :T_CLASS=>730344, :T_MODULE=>76808, :T_FLOAT=>240, :T_STRING=>882168, :T_REGEXP=>200350, :T_ARRAY=>714384, :T_HASH=>150408, :T_STRUCT=>800, :T_BIGNUM=>80, :T_FILE=>1160, :T_DATA=>1074338, :T_MATCH=>28280, :T_COMPLEX=>40, :T_RATIONAL=>40, :T_SYMBOL=>5080, :T_IMEMO=>325040, :T_ICLASS=>3280, :TOTAL=>4294688}
199
+ ```
200
+
72
201
  ## Development
73
202
 
74
203
  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.
@@ -85,4 +214,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
85
214
 
86
215
  ## Code of Conduct
87
216
 
88
- Everyone interacting in the SchwadPerformanceLogger project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/schwad_performance_logger/blob/master/CODE_OF_CONDUCT.md).
217
+ Everyone interacting in the SPL project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/schwad_performance_logger/blob/master/CODE_OF_CONDUCT.md).
@@ -12,7 +12,7 @@ module SchwadPerformanceLogger
12
12
  if opts.is_a?(Hash)
13
13
  PLogger.new(opts)
14
14
  else
15
- puts "I'm sorry, I don't know what you're trying to pass here!\n\n Please refer to the docs or pass an options hash https://github.com/oceanshq/schwad_performance_logger"
15
+ puts "I'm sorry, I don't know what you're trying to pass here!\n\n Please refer to the docs or pass an options hash https://github.com/schwad/schwad_performance_logger"
16
16
  end
17
17
  end
18
18
 
@@ -1,3 +1,3 @@
1
1
  module SchwadPerformanceLogger
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schwad_performance_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Schwaderer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-06 00:00:00.000000000 Z
11
+ date: 2019-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: get_process_mem
@@ -115,8 +115,6 @@ files:
115
115
  - lib/schwad_performance_logger.rb
116
116
  - lib/schwad_performance_logger/schwad_performance_logger.rb
117
117
  - lib/schwad_performance_logger/version.rb
118
- - schwad_performance_logger-0.2.0.gem
119
- - schwad_performance_logger-0.3.0.gem
120
118
  - schwad_performance_logger.gemspec
121
119
  homepage: https://schwad.github.io
122
120
  licenses:
@@ -137,7 +135,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
135
  - !ruby/object:Gem::Version
138
136
  version: '0'
139
137
  requirements: []
140
- rubygems_version: 3.0.6
138
+ rubyforge_project:
139
+ rubygems_version: 2.7.8
141
140
  signing_key:
142
141
  specification_version: 4
143
142
  summary: Track your memory and time performance in console, csv and/or logs.
Binary file
Binary file