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 +4 -4
- data/README.md +27 -15
- data/benchify.gemspec +1 -1
- data/bin/benchify +20 -16
- data/lib/benchify.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ab4739b8e35a289ef0bc93d42a07e0de279bbc6811c2a25158ec72755719011
|
4
|
+
data.tar.gz: 2ecbe780019eb29c010a0ea14634a53ae6744fe2c2a1e4efadca368e320c65b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
#
|
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
|
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
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
|
18
|
+
if test == :file
|
18
19
|
|
19
|
-
|
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.
|
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
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.
|
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-
|
11
|
+
date: 2021-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|