From bba945b3b967f1095388bf030196dba46d6a110f Mon Sep 17 00:00:00 2001 From: Nikita Zlobin Date: Mon, 30 Nov 2020 13:00:21 +0500 Subject: [PATCH 1/5] Enhanced example for memory usage executor, sync for all docs It seems, html help already had one free instance with -s option for persistance, though still used inner non-persistant chain for humanized output. --- doc/tint2.1 | 7 ++++--- doc/tint2.html | 5 +++-- doc/tint2.md | 7 ++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/doc/tint2.1 b/doc/tint2.1 index 040c2be..c985bca 100644 --- a/doc/tint2.1 +++ b/doc/tint2.1 @@ -831,10 +831,11 @@ execp_markup = 1 .PP .RS .nf +# "stdbuf -oL" noticed to give better performance than fflush() from awk code execp = new -execp_command = free | awk '/^\-/ { printf "Mem: '$(free \-h | awk '/^Mem:/ { print $2 }')' %.0f%%\\n", 100*$3/($3+$4); fflush(stdout) }' -execp_interval = 5 -execp_continuous = 0 +execp_command = free -b -s1 | stdbuf -oL awk '/^Mem:/ { printf "Mem: %.1fGi %.0f%%\n", $2 / (2^30), 100 * ($2 - $7) / $2 }' +execp_interval = 1 +execp_continuous = 1 .fi .RE .SS Network load diff --git a/doc/tint2.html b/doc/tint2.html index 033dc77..7266ab0 100644 --- a/doc/tint2.html +++ b/doc/tint2.html @@ -372,8 +372,9 @@ execp_continuous = 1 execp_interval = 1 execp_markup = 1 -
Memory usage
execp = new
-execp_command = free -s 2 | awk '/^-/ { printf "Mem: '$(free -h | awk '/^Mem:/ { print $2 }')' %.0f%\n", 100*$3/($3+$4); fflush(stdout) }'
+
Memory usage
# "stdbuf -oL" noticed to give better performance than fflush() from awk code
+execp = new
+execp_command = free -b -s1 | stdbuf -oL awk '/^Mem:/ { printf "Mem: %.1fGi %.0f%%\n", $2 / (2^30), 100 * ($2 - $7) / $2 }'
 execp_interval = 1
 execp_continuous = 1
 
diff --git a/doc/tint2.md b/doc/tint2.md index 313f815..5b6b1b9 100644 --- a/doc/tint2.md +++ b/doc/tint2.md @@ -694,10 +694,11 @@ execp_markup = 1 ##### Memory usage ``` +# "stdbuf -oL" noticed to give better performance than fflush() from awk code execp = new -execp_command = free | awk '/^-/ { printf "Mem: '$(free -h | awk '/^Mem:/ { print $2 }')' %.0f%%\n", 100*$3/($3+$4); fflush(stdout) }' -execp_interval = 5 -execp_continuous = 0 +execp_command = free -b -s1 | stdbuf -oL awk '/^Mem:/ { printf "Mem: %.1fGi %.0f%%\n", $2 / (2^30), 100 * ($2 - $7) / $2 }' +execp_interval = 1 +execp_continuous = 1 ``` ##### Network load From 975149642fccd9edb663d86d8630637ea5800d4e Mon Sep 17 00:00:00 2001 From: Nikita Zlobin Date: Sat, 5 Dec 2020 23:48:33 +0500 Subject: [PATCH 2/5] Use numfmt to get back human output in memory usage executor --- doc/tint2.1 | 4 ++-- doc/tint2.html | 4 ++-- doc/tint2.md | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/tint2.1 b/doc/tint2.1 index c985bca..3d62190 100644 --- a/doc/tint2.1 +++ b/doc/tint2.1 @@ -831,9 +831,9 @@ execp_markup = 1 .PP .RS .nf -# "stdbuf -oL" noticed to give better performance than fflush() from awk code +# Though unnecessary here, "stdbuf -oL" performs better than fflush() in awk code execp = new -execp_command = free -b -s1 | stdbuf -oL awk '/^Mem:/ { printf "Mem: %.1fGi %.0f%%\n", $2 / (2^30), 100 * ($2 - $7) / $2 }' +execp_command = free -b -s1 | stdbuf -oL awk '/^Mem:/ { c="numfmt --to=si"; print $2 |& c; c |& getline a; printf "Mem: %s %.0f%%\n", a, 100 * ($2 - $7) / $2 }' execp_interval = 1 execp_continuous = 1 .fi diff --git a/doc/tint2.html b/doc/tint2.html index 7266ab0..44cd3da 100644 --- a/doc/tint2.html +++ b/doc/tint2.html @@ -372,9 +372,9 @@ execp_continuous = 1 execp_interval = 1 execp_markup = 1
-
Memory usage
# "stdbuf -oL" noticed to give better performance than fflush() from awk code
+
Memory usage
# Though unnecessary here, "stdbuf -oL" performs better than fflush() in awk code
 execp = new
-execp_command = free -b -s1 | stdbuf -oL awk '/^Mem:/ { printf "Mem: %.1fGi %.0f%%\n", $2 / (2^30), 100 * ($2 - $7) / $2 }'
+execp_command = free -b -s1 | stdbuf -oL awk ‘/^Mem:/ { c=“numfmt –to=si”; print $2 |& c; c |& getline a; printf “Mem: %s %.0f%%\n”, a, 100 * ($2 - $7) / $2 }’
 execp_interval = 1
 execp_continuous = 1
 
diff --git a/doc/tint2.md b/doc/tint2.md index 5b6b1b9..d1a27b1 100644 --- a/doc/tint2.md +++ b/doc/tint2.md @@ -694,9 +694,9 @@ execp_markup = 1 ##### Memory usage ``` -# "stdbuf -oL" noticed to give better performance than fflush() from awk code +# Though unnecessary here, "stdbuf -oL" performs better than fflush() in awk code execp = new -execp_command = free -b -s1 | stdbuf -oL awk '/^Mem:/ { printf "Mem: %.1fGi %.0f%%\n", $2 / (2^30), 100 * ($2 - $7) / $2 }' +execp_command = free -b -s1 | stdbuf -oL awk '/^Mem:/ { c="numfmt --to=si"; print $2 |& c; c |& getline a; printf "Mem: %s %.0f%%\n", a, 100 * ($2 - $7) / $2 }' execp_interval = 1 execp_continuous = 1 ``` From 60ee870ae54aca5f8a247e45fcc71a6b24d64ac5 Mon Sep 17 00:00:00 2001 From: Nikita Zlobin Date: Thu, 24 Dec 2020 00:14:32 +0500 Subject: [PATCH 3/5] Oops, avoid gawk coprocess extension --- doc/tint2.1 | 2 +- doc/tint2.html | 2 +- doc/tint2.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/tint2.1 b/doc/tint2.1 index 3d62190..a0fadc1 100644 --- a/doc/tint2.1 +++ b/doc/tint2.1 @@ -833,7 +833,7 @@ execp_markup = 1 .nf # Though unnecessary here, "stdbuf -oL" performs better than fflush() in awk code execp = new -execp_command = free -b -s1 | stdbuf -oL awk '/^Mem:/ { c="numfmt --to=si"; print $2 |& c; c |& getline a; printf "Mem: %s %.0f%%\n", a, 100 * ($2 - $7) / $2 }' +execp_command = free -b -s1 | stdbuf -oL awk '/^Mem:/ { printf "Mem: %s %.0f%%\n", $2, 100 * ($2 - $7) / $2 }' | stdbuf -oL numfmt --to=iec-i --field=2 -d' ' execp_interval = 1 execp_continuous = 1 .fi diff --git a/doc/tint2.html b/doc/tint2.html index 44cd3da..97bdd77 100644 --- a/doc/tint2.html +++ b/doc/tint2.html @@ -374,7 +374,7 @@ execp_markup = 1
Memory usage
# Though unnecessary here, "stdbuf -oL" performs better than fflush() in awk code
 execp = new
-execp_command = free -b -s1 | stdbuf -oL awk ‘/^Mem:/ { c=“numfmt –to=si”; print $2 |& c; c |& getline a; printf “Mem: %s %.0f%%\n”, a, 100 * ($2 - $7) / $2 }’
+execp_command = free -b -s1 | stdbuf -oL awk '/^Mem:/ { printf "Mem: %s %.0f%%\n", $2, 100 * ($2 - $7) / $2 }' | stdbuf -oL numfmt --to=iec-i --field=2 -d' '
 execp_interval = 1
 execp_continuous = 1
 
diff --git a/doc/tint2.md b/doc/tint2.md index d1a27b1..6d6ecaf 100644 --- a/doc/tint2.md +++ b/doc/tint2.md @@ -696,7 +696,7 @@ execp_markup = 1 ``` # Though unnecessary here, "stdbuf -oL" performs better than fflush() in awk code execp = new -execp_command = free -b -s1 | stdbuf -oL awk '/^Mem:/ { c="numfmt --to=si"; print $2 |& c; c |& getline a; printf "Mem: %s %.0f%%\n", a, 100 * ($2 - $7) / $2 }' +execp_command = free -b -s1 | stdbuf -oL awk '/^Mem:/ { printf "Mem: %s %.0f%%\n", $2, 100 * ($2 - $7) / $2 }' | stdbuf -oL numfmt --to=iec-i --field=2 -d' ' execp_interval = 1 execp_continuous = 1 ``` From 795302fbafc800ec21eb96143f03ba62e0e6b304 Mon Sep 17 00:00:00 2001 From: Nikita Zlobin Date: Thu, 24 Dec 2020 00:22:48 +0500 Subject: [PATCH 4/5] More reasonable comment about stdbuf -oL --- doc/tint2.1 | 3 +-- doc/tint2.html | 5 ++--- doc/tint2.md | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/doc/tint2.1 b/doc/tint2.1 index a0fadc1..a553872 100644 --- a/doc/tint2.1 +++ b/doc/tint2.1 @@ -831,7 +831,7 @@ execp_markup = 1 .PP .RS .nf -# Though unnecessary here, "stdbuf -oL" performs better than fflush() in awk code +# Note the use of "stdbuf \-oL" to force the program to flush the output line by line. execp = new execp_command = free -b -s1 | stdbuf -oL awk '/^Mem:/ { printf "Mem: %s %.0f%%\n", $2, 100 * ($2 - $7) / $2 }' | stdbuf -oL numfmt --to=iec-i --field=2 -d' ' execp_interval = 1 @@ -842,7 +842,6 @@ execp_continuous = 1 .PP .RS .nf -# Note the use of "stdbuf \-oL" to force the program to flush the output line by line. execp = new execp_command = stdbuf \-oL bwm\-ng \-o csv \-t 1000 | awk \-F ';' '/total/ { printf "Net: %.0f Mb/s\\n", ($5*8/1.0e6) }; fflush(stdout)' execp_continuous = 1 diff --git a/doc/tint2.html b/doc/tint2.html index 97bdd77..5311c66 100644 --- a/doc/tint2.html +++ b/doc/tint2.html @@ -372,14 +372,13 @@ execp_continuous = 1 execp_interval = 1 execp_markup = 1 -
Memory usage
# Though unnecessary here, "stdbuf -oL" performs better than fflush() in awk code
+
Memory usage
# Note the use of "stdbuf -oL" to force the program to flush the output line by line.
 execp = new
 execp_command = free -b -s1 | stdbuf -oL awk '/^Mem:/ { printf "Mem: %s %.0f%%\n", $2, 100 * ($2 - $7) / $2 }' | stdbuf -oL numfmt --to=iec-i --field=2 -d' '
 execp_interval = 1
 execp_continuous = 1
 
-
Network load
# Note the use of "stdbuf -oL" to force the program to flush the output line by line.
-execp = new
+
Network load
execp = new
 execp_command = stdbuf -oL bwm-ng -o csv -t 1000 | awk -F ';' '/total/ { printf "Net: %.0f Mb/s\n", ($5*8/1.0e6) }; fflush(stdout)'
 execp_continuous = 1
 execp_interval = 1
diff --git a/doc/tint2.md b/doc/tint2.md
index 6d6ecaf..1e2d2f5 100644
--- a/doc/tint2.md
+++ b/doc/tint2.md
@@ -694,7 +694,7 @@ execp_markup = 1
 ##### Memory usage
 
 ```
-# Though unnecessary here, "stdbuf -oL" performs better than fflush() in awk code
+# Note the use of "stdbuf -oL" to force the program to flush the output line by line.
 execp = new
 execp_command = free -b -s1 | stdbuf -oL awk '/^Mem:/ { printf "Mem: %s %.0f%%\n", $2, 100 * ($2 - $7) / $2 }' | stdbuf -oL numfmt --to=iec-i --field=2 -d' '
 execp_interval = 1
@@ -704,7 +704,6 @@ execp_continuous = 1
 ##### Network load
 
 ```
-# Note the use of "stdbuf -oL" to force the program to flush the output line by line.
 execp = new
 execp_command = stdbuf -oL bwm-ng -o csv -t 1000 | awk -F ';' '/total/ { printf "Net: %.0f Mb/s\n", ($5*8/1.0e6) }; fflush(stdout)'
 execp_continuous = 1

From ca3588cab04e6dfa93b86eac18c6abc4614a0e17 Mon Sep 17 00:00:00 2001
From: Nikita Zlobin 
Date: Thu, 24 Dec 2020 00:24:36 +0500
Subject: [PATCH 5/5] Improve network bandwidth executor example too (stdbuf
 -oL)

If memusage example got stdbuf -oL awk, why further examples
can't use same?
---
 doc/tint2.1    | 2 +-
 doc/tint2.html | 2 +-
 doc/tint2.md   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/doc/tint2.1 b/doc/tint2.1
index a553872..c745986 100644
--- a/doc/tint2.1
+++ b/doc/tint2.1
@@ -843,7 +843,7 @@ execp_continuous = 1
 .RS
 .nf
 execp = new
-execp_command = stdbuf \-oL bwm\-ng \-o csv \-t 1000 | awk \-F ';' '/total/ { printf "Net: %.0f Mb/s\\n", ($5*8/1.0e6) }; fflush(stdout)'
+execp_command = stdbuf \-oL bwm\-ng \-o csv \-t 1000 | stdbuf -oL awk \-F ';' '/total/ { printf "Net: %.0f Mb/s\\n", ($5*8/1.0e6) }'
 execp_continuous = 1
 execp_interval = 1
 .fi
diff --git a/doc/tint2.html b/doc/tint2.html
index 5311c66..2acd5ea 100644
--- a/doc/tint2.html
+++ b/doc/tint2.html
@@ -379,7 +379,7 @@ execp_interval = 1
 execp_continuous = 1
 
Network load
execp = new
-execp_command = stdbuf -oL bwm-ng -o csv -t 1000 | awk -F ';' '/total/ { printf "Net: %.0f Mb/s\n", ($5*8/1.0e6) }; fflush(stdout)'
+execp_command = stdbuf -oL bwm-ng -o csv -t 1000 | stdbuf -oL awk -F ';' '/total/ { printf "Net: %.0f Mb/s\n", ($5*8/1.0e6) }'
 execp_continuous = 1
 execp_interval = 1
 
diff --git a/doc/tint2.md b/doc/tint2.md index 1e2d2f5..af52798 100644 --- a/doc/tint2.md +++ b/doc/tint2.md @@ -705,7 +705,7 @@ execp_continuous = 1 ``` execp = new -execp_command = stdbuf -oL bwm-ng -o csv -t 1000 | awk -F ';' '/total/ { printf "Net: %.0f Mb/s\n", ($5*8/1.0e6) }; fflush(stdout)' +execp_command = stdbuf -oL bwm-ng -o csv -t 1000 | stdbuf -oL awk -F ';' '/total/ { printf "Net: %.0f Mb/s\n", ($5*8/1.0e6) }' execp_continuous = 1 execp_interval = 1 ```