ips 0.2.0 → 0.3.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 +4 -4
- data/lib/ips/display.rb +28 -5
- data/lib/ips/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5c8dde979505d34763745a2f6dcf6f9df0a8e6396fdd2351b769282393839417
|
|
4
|
+
data.tar.gz: 4225c76063e8a905bbf14efb5eb8ee000a030b4f674d6c2c9cef9571f007d4b6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d0178e0e87a6913dc3134f4e748bdb795f16e4fb2a2cca10c3f1fc7e7dc9a4615e5bb3d45c12aff7adb6a0a12afd644392b77f07bd080ee91e382734b0ea1b8e
|
|
7
|
+
data.tar.gz: 199d08e24ae772bc5030a9f8daf63b4b453cfef6e8623110fd292ae70d5d1ca1f806bcaae7b86e364dae1850deea6a398b4b01426166c153cbc45917ec823644
|
data/lib/ips/display.rb
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
begin
|
|
4
|
+
require "io/console"
|
|
5
|
+
rescue LoadError
|
|
6
|
+
end
|
|
7
|
+
|
|
3
8
|
module IPS
|
|
4
9
|
class Display
|
|
5
10
|
BAR_WIDTH = 30
|
|
@@ -8,14 +13,19 @@ module IPS
|
|
|
8
13
|
@out = out
|
|
9
14
|
@max_label = labels.map(&:size).max
|
|
10
15
|
@max_label = 20 if @max_label < 20
|
|
11
|
-
@tty = @out.tty? && !debug
|
|
16
|
+
@tty = @out.tty? && !debug && terminal_wide_enough?
|
|
12
17
|
end
|
|
13
18
|
|
|
14
19
|
def start_item(label, total_ns)
|
|
15
20
|
@item_label = label
|
|
16
21
|
@item_start = Timing.now
|
|
17
22
|
@item_total_ns = total_ns
|
|
18
|
-
|
|
23
|
+
if @tty
|
|
24
|
+
progress
|
|
25
|
+
else
|
|
26
|
+
@out.print "%#{@max_label}s: " % label
|
|
27
|
+
@out.flush
|
|
28
|
+
end
|
|
19
29
|
end
|
|
20
30
|
|
|
21
31
|
def progress(estimate: nil)
|
|
@@ -33,11 +43,16 @@ module IPS
|
|
|
33
43
|
end
|
|
34
44
|
|
|
35
45
|
def finish_item(result)
|
|
36
|
-
@out.print "\r\e[2K" if @tty
|
|
37
46
|
gc = result.gc_pct >= 1.0 ? ", GC %4.1f%%" % result.gc_pct : ""
|
|
38
47
|
error = result.error_pct > 100 ? ">100" : "%4.1f" % result.error_pct
|
|
39
|
-
|
|
40
|
-
|
|
48
|
+
if @tty
|
|
49
|
+
@out.print "\r\e[2K"
|
|
50
|
+
@out.printf "%#{@max_label}s: %10s i/s (±%s%%%s)\n",
|
|
51
|
+
result.label, format_ips(result.ips), error, gc
|
|
52
|
+
else
|
|
53
|
+
@out.printf "%10s i/s (±%s%%%s)\n",
|
|
54
|
+
format_ips(result.ips), error, gc
|
|
55
|
+
end
|
|
41
56
|
end
|
|
42
57
|
|
|
43
58
|
def summary(results)
|
|
@@ -63,6 +78,14 @@ module IPS
|
|
|
63
78
|
end
|
|
64
79
|
end
|
|
65
80
|
|
|
81
|
+
def terminal_wide_enough?
|
|
82
|
+
return true unless @out.respond_to?(:winsize)
|
|
83
|
+
# label + ": " + estimate + " " + bar + " ETA Ns "
|
|
84
|
+
min_width = @max_label + 2 + 14 + 1 + BAR_WIDTH + 8
|
|
85
|
+
_, cols = @out.winsize
|
|
86
|
+
cols >= min_width
|
|
87
|
+
end
|
|
88
|
+
|
|
66
89
|
def format_ips(ips)
|
|
67
90
|
Display.format_ips(ips)
|
|
68
91
|
end
|
data/lib/ips/version.rb
CHANGED