benchify 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: 02f60ea5575a2eaa1de387bb7631625c9c7c8ffa373b1f77f6c33e9dc9faf47b
4
- data.tar.gz: 0025bd883e6b174893ff6acfb3a4125a457ca629639656037c43a03be5ba5677
3
+ metadata.gz: 9ab4739b8e35a289ef0bc93d42a07e0de279bbc6811c2a25158ec72755719011
4
+ data.tar.gz: 2ecbe780019eb29c010a0ea14634a53ae6744fe2c2a1e4efadca368e320c65b3
5
5
  SHA512:
6
- metadata.gz: 17f5037e570a19dafa806867b5623e0ac73de38205ed8c1abfe73daa1929a2f94be811ff5a5ef238b5451975886100c1a98121644f1842b7a558b5cd6ec87f68
7
- data.tar.gz: 2853908b8eabded8dd289dd0ee53b6f45ef377ba3e336234350be7bf5a479d8703a6b6dfb65b8d478b004d10f4d837bcca8a0cddfd1abe7a63caf826171b20fd
6
+ metadata.gz: f44aaf4bbcd2921215a2857bfe85f5dba5942ee5c02de193b1e15dcc792f4ecf0882a99db1f60bfb01665975ac6bd7fd9488213d80aeb863b07fb3a1cadfe998
7
+ data.tar.gz: a5d0c9d184bfbba77077cf75fdfcecdfcd6893422dbda8f598f75812c9040d971ae63d87fee3d6934b577833ce8fae259b34d3ded489d83234eb7f49b67cbdf5
data/README.md CHANGED
@@ -3,13 +3,16 @@
3
3
  **Benchmark Source-Code:**
4
4
 
5
5
  ```ruby
6
- # #measure is alias for #call
6
+ # initialize new object
7
+ # accept type (:symbol) and message ('string')
7
8
 
8
- benchmark = Benchify.new
9
+ benchmark = Benchify.new :min, 'processed time in minutes:'
9
10
  # or
10
- benchmark = Benchmark.new
11
+ benchmark = Benchmark.new :sec
11
12
 
12
13
 
14
+ # measure is alias for call
15
+
13
16
  benchmark.call { YOUR CODE HERE }
14
17
  # or
15
18
  benchmark.measure do
@@ -24,27 +27,36 @@ Make sure your script has environment defined ( shebang )
24
27
  ` #!/usr/bin/env ruby `
25
28
 
26
29
  ```ruby
27
- benchify SCRIPT-1.rb SCRIPT-2.py SCRIPT-3.sh
30
+ benchify script_1.rb script_2.py script_3.sh
31
+ ```
32
+
33
+ Or use `-e` to benchmark shell command
34
+
35
+ ```ruby
36
+ benchify -e 'free -m | head -n 2' 'some other command'
28
37
  ```
29
38
 
30
39
  # About
31
40
 
32
41
  ```ruby
33
- benchmark = Benchmark.new
42
+ benchmark = Benchmark.new :ms, ' counted milliseconds:'
43
+
34
44
  benchmark.call { ... }
45
+ benchmark.measure('change_message:') { ... }
35
46
 
36
47
  Attributes:
37
48
 
38
- benchmark.message
39
- benchmark.type
40
- benchmark.start
41
- benchmark.end
42
- benchmark.total
43
- benchmark.time
44
- benchmark.result
45
- benchmark.in_seconds
46
- benchmark.in_minutes
47
- benchmark.in_hours
49
+ benchmark.message => 'processed time:'
50
+ benchmark.type => :sec
51
+ benchmark.start => Time.now when start
52
+ benchmark.end => Time.now when end
53
+ benchmark.total => Total seconds - float
54
+ benchmark.time => counted time by type (:sec)
55
+ benchmark.result => message + time + type (processed time: 22.124 sec)
56
+ benchmark.in_seconds => access time in seconds
57
+ benchmark.in_minutes => access time in minutes
58
+ benchmark.in_hours => access time in hours
59
+ benchmark.in_ms => access time in milliseconds
48
60
  ```
49
61
 
50
62
  # TO-DO
data/benchify.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'benchify'
5
- s.version = '0.1.0'
5
+ s.version = '0.1.1'
6
6
  s.summary = 'Benchmark measures for Code and/or Terminal'
7
7
  s.description = <<~DESC
8
8
  Benchmark Ruby methods from source code, or any script from terminal.
data/bin/benchify CHANGED
@@ -11,29 +11,33 @@ require_relative '../lib/benchify'
11
11
  else
12
12
 
13
13
  benchmark = Benchify.new
14
+ test = ARGV.include?('-e') ? :cli : :file
14
15
 
15
16
  ARGV.each do |script|
16
17
 
17
- if File.executable?(script)
18
+ if test == :file
18
19
 
19
- benchmark.measure { system "./#{script}" }
20
- puts benchmark.result
21
-
22
- else
23
-
24
- puts "[!] NOT EXECUTABLE!"
25
- puts "[*] Do you want to give [#{script}] executable permission?"
26
-
27
- answer = STDIN.gets.chomp!
28
-
29
- unless %w[y Y yes YES].include? answer
30
- next
31
- else
32
- system "sudo chmod +x #{script}"
20
+ if File.executable?(script)
33
21
  benchmark.measure { system "./#{script}" }
34
- puts benchmark.data
22
+ puts benchmark.result
23
+ else
24
+ puts "[!] NOT EXECUTABLE!"
25
+ puts "[*] Do you want to give [#{script}] executable permission?"
26
+ answer = STDIN.gets.chomp!
27
+
28
+ unless %w[y Y yes YES].include? answer
29
+ next
30
+ else
31
+ system "sudo chmod +x #{script}"
32
+ benchmark.measure { system "./#{script}" }
33
+ puts benchmark.result
34
+ end
35
35
  end
36
36
 
37
+ else
38
+ next if script == '-e'
39
+ benchmark.call { system "#{script}" }
40
+ puts benchmark.result
37
41
  end
38
42
  end
39
43
  end
data/lib/benchify.rb CHANGED
@@ -31,7 +31,7 @@ class Benchify
31
31
  end
32
32
 
33
33
 
34
- def call( msg = nil, &operation )
34
+ def call( message = nil, &operation )
35
35
 
36
36
  msg = message || @message
37
37
  @start = Time.now
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: benchify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - decentralizuj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-15 00:00:00.000000000 Z
11
+ date: 2021-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler