schwad_performance_logger 0.1.0 → 0.2.0

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: 3dc7e1108b9ce7a1a47286a502350df63f11390d
4
- data.tar.gz: f6fe234f315b1e57ca7c8bb5c24b7f162661f286
3
+ metadata.gz: 674ca62fc24c2236c78edd52c4c17fab4c46d946
4
+ data.tar.gz: 8a2f881fc9ab052022799e2f634599c7b9a59d6c
5
5
  SHA512:
6
- metadata.gz: 67e02cca112220cfb555a046326c06e4e11ba3c6111772451bda02a3fad12c4ba232040d921b2d8f80c2ee11c321dd68da6fa7c91aa5af2481fe6f7ab927907b
7
- data.tar.gz: 3d79833a6f45e85189fa76acb9a67e997e0cf4bc3f4fbed9f855d9b1faf865d7022306d85eaa56df87a5c0e140de297b0ded878a51e17e97596fc82d5b1c3572
6
+ metadata.gz: 13cd63c83a5ab428a8665324a6f691d08b523949797374ea34a283d5c61b36041ffec4b426edb13f7ec5801dd2ca12105584f9046a49bd622534f3a920899e8f
7
+ data.tar.gz: 5586264c2c7028890803417ee1875c65acec5731b3345d16c68d0181ab40afb044c198df6970eeb9b15078e30fef8abc17a329b20731a84cb1372094fe1693e5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- schwad_performance_logger (0.1.0)
4
+ schwad_performance_logger (0.2.0)
5
5
  get_process_mem
6
6
 
7
7
  GEM
@@ -29,9 +29,9 @@ PLATFORMS
29
29
 
30
30
  DEPENDENCIES
31
31
  bundler (~> 1.16)
32
- schwad_performance_logger!
33
32
  rake (~> 10.0)
34
33
  rspec (~> 3.0)
34
+ schwad_performance_logger!
35
35
 
36
36
  BUNDLED WITH
37
37
  1.16.2
data/README.md CHANGED
@@ -5,9 +5,6 @@ the SchwadPerformanceLogger object, as well as deltas between each check. The ou
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
 
8
- **THIS GEM IS IN DEVELOPMENT**: Major 'todo' left is to ensure that CSV and logger
9
- elements actually write to user's root directory and not the gem's.
10
-
11
8
  ## Installation
12
9
 
13
10
  Add this line to your application's Gemfile:
@@ -26,7 +23,7 @@ Or install it yourself as:
26
23
 
27
24
  ## Usage
28
25
 
29
- `pl = SchwadPerformanceLogger.new`
26
+ `pl = SchwadPerformanceLogger.new({full_memo: 'Check extract method refactoring'})`
30
27
 
31
28
  ```
32
29
  **********************************************************************
@@ -46,6 +43,8 @@ Starting Test memo. Current memory: 12(Mb), difference of 0 (mb) since beginning
46
43
 
47
44
  ### Options
48
45
 
46
+ `full_memo` option adds an extra header in the `log` outputs as well as a header to each new set of csv outputs. This is not to be confused with the 'per-run' message passed to `#log_performance` which is only passed to that check.
47
+
49
48
  To disable any of the outputs:
50
49
 
51
50
  `SchwadPerformanceLogger.new({puts: false, log: false, csv: false})`
@@ -55,6 +54,20 @@ you can actually see the log as it goes by. This does not affect the 'time' meas
55
54
 
56
55
  `SchwadPerformanceLogger.new({pause: 8})`
57
56
 
57
+ ## Usage example:
58
+
59
+ ```
60
+ pl = SchwadPerformanceLogger.new({pause: 3, full_memo: 'Retry object-oriented approach.', log: false})
61
+ pl.log_performance('check status before writing to database')
62
+
63
+ # code here
64
+
65
+ pl.log_performance('check status after writing to database')
66
+
67
+ # code
68
+
69
+ pl.log_performance('inspect final performance after executing service')
70
+ ```
58
71
 
59
72
  ## Development
60
73
 
@@ -17,11 +17,12 @@ class PLogger
17
17
  attr_reader :options
18
18
 
19
19
  def initialize( options = {} )
20
- # system('mkdir log/schwad_performance_logger')
21
- # filename = "./log/schwad_performance_logger/performance-#{Time.now.strftime("%e-%m_%l:%M%p")}.log"
22
- # File.write(filename, "")
23
- # another_empty_csv_row
24
- # @logger = Logger.new(filename)
20
+ system('mkdir log')
21
+ system('mkdir log/schwad_performance_logger')
22
+ filename = "./log/schwad_performance_logger/performance-#{Time.now.strftime("%e-%m_%l:%M%p")}.log"
23
+ File.write(filename, "")
24
+ another_empty_csv_row
25
+ @logger = Logger.new(filename)
25
26
  @options = options
26
27
  @sleep_amount = options[:pause].to_i
27
28
  @initial_memory = GetProcessMem.new.mb.round
@@ -39,8 +40,8 @@ class PLogger
39
40
  def log_performance(memo=nil)
40
41
  update_checks
41
42
  puts_performance(memo) unless @options[:puts] == false
42
- # logger_performance(memo) unless @options[:log] == false
43
- # csv_performance(memo) unless @options[:csv] == false
43
+ logger_performance(memo) unless @options[:log] == false
44
+ csv_performance(memo) unless @options[:csv] == false
44
45
  sleep @sleep_amount
45
46
  end
46
47
 
@@ -53,7 +54,7 @@ class PLogger
53
54
  end
54
55
 
55
56
  def logger_performance(memo)
56
- @logger.log(1, "\n\n#{memo}: \n\n Current Memory: #{@current_memory} \n\n Memory Since Start: #{@delta_memory}\n\n Memory Since Last Run: #{@second_delta_memory}\n\n Time Passed: #{@delta_time} \n\n Time Since Last Run: #{@second_delta_time} ")
57
+ @logger.log(1, "#{options[:full_memo]}\n----------------------\n\n#{memo}: \n\n Current Memory: #{@current_memory} \n\n Memory Since Start: #{@delta_memory}\n\n Memory Since Last Run: #{@second_delta_memory}\n\n Time Passed: #{@delta_time} \n\n Time Since Last Run: #{@second_delta_time}\n--------------------\n\n ")
57
58
  end
58
59
 
59
60
  def another_empty_csv_row
@@ -64,7 +65,7 @@ class PLogger
64
65
 
65
66
  def csv_performance(memo)
66
67
  CSV.open("schwad_performance_logger_measurements.csv", "ab") do |csv|
67
- csv << [@options[:csv_memo], memo, @current_memory, @delta_memory, @second_delta_memory, @delta_time, @second_delta_time]
68
+ csv << [@options[:full_memo], memo, @current_memory, @delta_memory, @second_delta_memory, @delta_time, @second_delta_time]
68
69
  end
69
70
  end
70
71
 
@@ -1,3 +1,3 @@
1
1
  module SchwadPerformanceLogger
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.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.1.0
4
+ version: 0.2.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: 2018-11-29 00:00:00.000000000 Z
11
+ date: 2018-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: get_process_mem