but 0.1.2 → 0.1.3

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: 853bfa5259d6c243f2728c71d7dd1575914cb38a29c1b40dcf39b78833fd670f
4
- data.tar.gz: b4d65cf498abbc277d1ec5280d6de2542a48810ac20f58f36c449dbf3410f493
3
+ metadata.gz: 7a401f4f83816e46b9a0a8dd97b84f4da1c1ef3141e20c750d902a98ca7050b5
4
+ data.tar.gz: bf75f25a1d4f0eca838d60f7b7f21c1db3ad3e18f1398b3387d7b1d414b4e3a4
5
5
  SHA512:
6
- metadata.gz: b90007c89eaa18486ebae63374caa47c3b32526fc58ac90b48542e0aa0cb67253caaf2336d56331218f84a7e319a023738718c1dc16a61c85ddef6937f93e68b
7
- data.tar.gz: 74ea9639c7aaaaf9bf06db499e3031d97b3e48ccf332d9aa699ea18e93b7ad257a5065bf451018dce7672a02e045e75e5d50c488e776ff87b3fe73456e7536ca
6
+ metadata.gz: f6e61db7075302c71a5ac845aeb85433a75fbe44d90e785a81ebf0025ff80bde37e4436678f2a1d445d5438b73b1cc9905ff3222ae33de9683478e06337c3fa1
7
+ data.tar.gz: 6b854b4002ec51e9577ab01e0cc0b05280dff03741e1add324d048cad06ce11cae2c036c073ee765c05896e51a622def90f44008f6177145711b63d67f409431
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- but (0.1.2)
4
+ but (0.1.3)
5
5
  colorize
6
+ ruby-prof
6
7
  thor
7
8
 
8
9
  GEM
@@ -129,6 +130,7 @@ GEM
129
130
  unicode-display_width (>= 1.4.0, < 2.0)
130
131
  rubocop-ast (0.0.3)
131
132
  parser (>= 2.7.0.1)
133
+ ruby-prof (1.4.1)
132
134
  ruby-progressbar (1.10.1)
133
135
  shellany (0.0.1)
134
136
  sys-uname (1.2.1)
data/README.md CHANGED
@@ -95,6 +95,39 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
95
95
 
96
96
  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).
97
97
 
98
+ ### Benchmarking and Profiling
99
+
100
+ #### Benchmarking
101
+
102
+ Each subcommand can be benchmarked by
103
+
104
+ ```
105
+ ### Garbage collector enabled
106
+ but command subcommand --measure --gc
107
+
108
+ #or
109
+
110
+ ### Garbage collector disabled
111
+ but command subcommand --measure --nogc
112
+ ```
113
+
114
+ #### Profiling
115
+
116
+ Each subcommand can be profiled using ruby prof
117
+
118
+ ```
119
+ but command --profile <MEASURING METHOD>
120
+ ```
121
+
122
+ where possible options are
123
+
124
+ ```
125
+ but command --profile WALL_TIME
126
+ but command --profile PROCESS_TIME
127
+ but command --profile ALLOCATIONS
128
+ but command --profile MEMORY
129
+ ```
130
+
98
131
  ### Contributing
99
132
 
100
133
  Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/but. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -48,6 +48,7 @@ Gem::Specification.new do |spec|
48
48
 
49
49
  spec.add_dependency 'thor'
50
50
  spec.add_dependency 'colorize'
51
+ spec.add_dependency 'ruby-prof'
51
52
 
52
53
 
53
54
  spec.metadata = { "source_code_uri" => "https://git.computational.bio.uni-giessen.de/rmueller/bcf_user_tools" }
@@ -17,6 +17,7 @@ module But
17
17
  class How < Thor
18
18
  class_option :measure, :type => :boolean, :default => false
19
19
  class_option :gc, :type => :boolean, :default => true
20
+ class_option :profile, :aliases => '-p', required: false, desc: 'create a ruby prof profile; Possible values: MEMORY, ALLOCATIONS, WALL_TIME, PROCESS_TIME'
20
21
 
21
22
  desc "messy am I?", "How messed up is your home?"
22
23
  def messy(*words)
@@ -24,6 +25,10 @@ module But
24
25
  measure(options) do
25
26
  say But::HomeKeeper.judge
26
27
  end
28
+ elsif options[:profile]
29
+ profile(options) do
30
+ say But::HomeKeeper.judge
31
+ end
27
32
  else
28
33
  say But::HomeKeeper.judge
29
34
  end
@@ -1,5 +1,7 @@
1
1
  require "json"
2
2
  require "benchmark"
3
+ require "rubygems"
4
+ require "ruby-prof"
3
5
 
4
6
  #inspired by Ruby Performance Optimization: Alexander Dymo
5
7
  def measure(options={}, &block)
@@ -31,3 +33,36 @@ def measure(options={}, &block)
31
33
  }
32
34
  }.to_json)
33
35
  end
36
+
37
+
38
+ def profile(options={}, &block)
39
+ measure_mode = options[:profile].upcase
40
+ RubyProf.measure_mode = RubyProf.const_get(measure_mode)
41
+
42
+ case measure_mode
43
+ when "WALL_TIME"
44
+ GC.disable
45
+ when "PROCESS_TIME"
46
+ GC.disable
47
+ when "ALLOCATIONS"
48
+ #GC.enable_stats
49
+ when "MEMORY"
50
+ #GC.enable_stats
51
+ else
52
+ end
53
+
54
+ result = RubyProf.profile do
55
+ yield
56
+ end
57
+
58
+ printer_g = RubyProf::GraphHtmlPrinter.new(result)
59
+ printer_f = RubyProf::FlatPrinter.new(result)
60
+ printer_c = RubyProf::CallTreePrinter.new(result)
61
+ unless measure_mode == "MEMORY"
62
+ printer_g.print(File.open(measure_mode + "_graph.html","w"))
63
+ printer_f.print(File.open(measure_mode + "_flat.txt","w"))
64
+ end
65
+ printer_c.print(options)
66
+
67
+ puts "Profiles written for #{measure_mode}"
68
+ end
@@ -1,3 +1,3 @@
1
1
  module But
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: but
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raphael Müller
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: ruby-prof
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
181
195
  description: BCF admins have a hard live. Their user's don't keep their $HOMES and
182
196
  other working places clean. It appears that some users don't know that they use
183
197
  too much space in their home or don't clean used directories on cluster (or other)