app-benchmarks/nbench, a commonly used benchmark utility has some of the worst code in existence. Revolting in many cases. nbench is virtually dead upstream. Also since it has to stay compatible with previous versions it includes nastiness like DOS specific code, so I decided to fork it and create cleanbench. cleanbench should be portable to platforms with sane ANSI C compilers. cleanbench is nbench with major cleaning, reformatting, and all around making it decent code. Specifically, this entails things like using libproccpuinfo[*], stripping huge amounts of entirely unused code, stripping DOS, Mac OS Classic, and Windows 3.1 support, fixing countless warnings, and splitting the 4445 line nbench1.c file into individual files for each benchmark. Check the code, you'd be amazed. The benchmark results are exactly the same. No tests have been altered other than to clean code and remove cruft. For comparison, sloccount reports nbench-2.2.3 ansic: 5217 (98.94%) sh: 56 (1.06%) cleanbench-1.0 ansic: 3084 (98.28%) sh: 54 (1.72%) cleanbench is a 40% reduction in SLOC over nbench! The sizes of binaries compiled with gcc-4.2.4 and CFLAGS="-O3 -march-k8 -msse3" are nbench-2.2.3 - 64K cleanbench-1.0 - 46K There's more to do and to clean, but it's at a good initial state. Please import into portage. [*] bug 137043
Created attachment 175236 [details] cleanbench-1.0 ebuild
Doesn't the makefile override what you pass for CC and CFLAGS and LINKFLAGS is never used in the makefile. Also please use emake instead of make. Thanks. Serkan
Created attachment 175269 [details] fixed cleanbench 1.0 ebuild I believe this ebuild fixes the things mentioned previously. Please review.
(In reply to comment #3) > Created an attachment (id=175269) [edit] > fixed cleanbench 1.0 ebuild > > I believe this ebuild fixes the things mentioned previously. Please review. > What I meant was the package's Makefile overrides the enviroments CFLAGS,CC and doesn't respect LDFLAGS. So, cleanbench's Makefile needs to be fixed actually. Flameeyes' article[1] has a part explaining it. 1: http://lwn.net/Articles/277132/ @Flameeyes: Adding you for suggestions. Thanks.
The sed should be in src_unpack (or prepare for EAPI=2), dobin and doins should be checked with || die in case of failure. As for the Makefile, since there is a cleanbench.o object listed, you can just replace LIBS with LDLIBS and replace the rule all: $(OBJS) with all: cleanbench cleanbench: $(OBJS) and it will respect LDFLAGS and build properly; but it would require changes to other parts of the makefile to work properly anyway: the .c -> .o transformation can be made much shorter, by using something like OPTFLAGS ?= -march= ... override CFLAGS = $(OPTFLAGS) $(WARN) and then removing all the rules. sysinfo.sh is a bit of a problem, but that's beside the point I guess.