New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Benchy - Benchmark with color !
Following suggestions taken from my previous thread, I have employ colored output as default option. It should detect whether the terminal supported 256 colors and proceed to use it if so— otherwise there will be no color at all.
If it's not too much to ask, can you test it out and give me feedback on it ?
wget -qO- benchy.pw | bash
or
curl -Ls benchy.pw | bash
Also check the Usage section to explore several variations to launch the script.
Comments
I've just tried it and it seems to be working just fine, all colors were there
Overall, it looks good, but personally, I would minimize the number of colors used.
I tend to run yabs with | tee yabs.bench
This lets me view and store the output.
Of course this also works for benchy but the output is not in colour.
You can store the output by appending
-o
or--output
. Like so:It will save the output to file named
benchy.log
.It will save the output to file named benchy.log.
Thanks - I should have RTFM
Doing the above, benchy.log is not in colour however I appreciate --color=yes could be added. I would suggest if default display is in colour then file should also default to color?
looking cool!!
I've been using bench.im & bench.sh. Now another option.
Initially its behavior was like you mentioned, but the file would be filled with ansi codes and control sequence. I have embedded image to show you what I meant → https://imgur.com/a/3UHAOMw
This is why I filter the output first before outputting to log and later to sprunge.us— to remove any trace of gibberish escape codes.
If you're fine with this, I can create
--color=force
to have your desired result.I understand your logic, on sprunge.us it certainly makes sense to have the 'plain' output.
When I use a local file it is purely for viewing so I would just cat benchy.log. I do however appreciate that the log file could be processed by something else and having all the escape sequences would just be a nightmare to strip out.
So my preference would be if output is displayed in colour then local file should match the display and sprunge.us should remain plain. If I need to process benchy.log then I should use --color=no
I accept it is all down to how people use the software so my requirements may be either in the minority or majority.
Looks good! Great work.
Is pipe to
bash
is require? and looks tput is broke on OpenBSD and script complain about /proc/cpuinfo not found.I will do PR today, script looks nice I like it so far.
No it is working on
sh
too, you may try that. Somebody has opened PR for OpenBSD support.Don't know about *bsd's tput, but a quick glance on its man page show it doesn't support color-- only solution I see is to exclude color if the host machine is *BSD.
Looks sweet! Great work man
I just pushed this feature to upstream, you may pass
--color=force
or-c force
argument to display outputted file in color, this doesn't affect the output sent to sprunge.us which should be colorless.I like the colours. I would expect the output file to default to plain text, no weird control codes. No problem with there being an override, if someone might need/desire it.
Yep, output file only have color if you add
--color=force
, otherwise it will stay colorless.i love it has the option to use speedtest.net instead of iperf,
good job
woot benchy! love it!
I got this error when using
sh
What if you download it first then manually execute it, do you encounter same problem ?
If the problem persist, probably very specific to *BSD line, unfortunately as I never work with *bsd machine before, I can't be of more help. Meanwhile I'll search a way to run *bsd on my vps so I can troubleshoot this problem.
Thanks ! This would not have been possible without your support
Before you go that far, it's probably worthwhile to fix the 30 issues noted by shellcheck. Fixing those will likely expose others. But once it's no longer finding fault in your script, there's a much higher chance it will "just work".
Also, test it with
ash
, heirloom sh,mksh
, andksh93
. ash is kinda the bare minimum shell. heirloom sh is a very traditional sh. mksh is the shell shipped by Android. ksh93 is basically the shell POSIX sh was documented against (and that bash tries/tried to mimic).Also, I looked at line 975 and I can kind of see why a shell would be distressed by that syntax. Try moving that
case
into a function. I'm not entirely sure that your order of operations is guaranteed by POSIX to work as you expect them to.It is working on my end with
ash
,dash
,mksh
,ksh
— except heirloom sh because I'm unable to locate their installable binary.Have followed several shellcheck recommendation, though I left some of them (e.g. SC2046 completely broke the argument parsing). Good call on that.
You'll likely need to build heirloom sh from the sources on sourceforge. It's very much a legacy-compatibility shell, but my experience is that getting a script to run happily in both heirloom sh and ksh93 is the lowest-effort way to hit all not-buggy shells once making shellcheck happy.
Also, make sure your distro has ksh93 as
ksh
and not the ancient pdksh that mksh was forked from:echo ${sh.version}
I downloaded heirloom-sh-050706.tar.bz2 from this link, extract it and found bunch of *.c file and one makefile, I do
make
and it produce a executable namedsh
and symlink to it under the namejsh
. I triedsudo make install
but it's not working with following error.Then I just type
./sh
, it bring me to new shell session (is this heirloom ?), I executebenchy
on it— finished without any issue. So does this mean it passes the compatibility check ?Wow looking great, loving it!
You probably don't want to
make install
it as the heirloom tools make certain assumptions about your system which almost certainly aren't true if you're not trying to run a lot of old tools, and if you're on Linux.But did you change the shebang of
benchy
or run./sh benchy
? If you just runbenchy
as-is, you will not be testing the newly-compiled shell.If it's working for you in even heirloom sh, @ailice will probably need to provide more information to ensure that it's made to work for them. Like which OpenBSD version and which architecture.
I'd call the observed behavior an OpenBSD bug, honestly, from what I'm seeing. Granted, it'd only be a bug in practice rather than in theory, as I came up with a few "valid" ways to parse the line in question aside from the accepted way.
@Liso Not working on AlmaLinux release 8.7 (Stone Smilodon). No error either. Same with yabs.sh . bench.sh is working fine though.
Well I spoke too soon, I tried changing the shebang to
sh
file on heirloom dir, it immediately spouting this error:benchy: syntax error at line 24:
cred=$' unexpected`.Looks like heirloom doesn't support
$()
syntax. I'll see if there's anything more.What do you mean no error ? Is there no output at all ?
Yes, that's right. No output at all.
Its OpenBSD 7.2 amd64, AFAIK
sh
was symlink withksh
on OpenBSD. I also haveksh
on Alpine but script running fine.This probably some OpenBSD stuff