Skip to content

Instantly share code, notes, and snippets.

@lbmn
Last active May 27, 2019 21:21
Show Gist options
  • Select an option

  • Save lbmn/4a687dca0c939b505b8f9107879af07f to your computer and use it in GitHub Desktop.

Select an option

Save lbmn/4a687dca0c939b505b8f9107879af07f to your computer and use it in GitHub Desktop.
MODULE: GCC BYTES: GCC UPX: CLANG: CLANG UPX:
__none__ 33,288 20,532 37,048 18,128
httpclient 69,888 32,820 70,320 29,736
smtp 69,000 32,820 69,344 29,480
logging 69,808 36,916 69,256 30,356
unittest 60,232 32,820 63,960 30,284
nre 59,288 32,820 62,840 29,284
asyncftpclient 56,360 28,724 60,808 27,600
ftpclient 56,200 28,724 60,632 27,652
asynchttpserver 56,144 28,724 56,480 27,492
asyncfile 55,728 28,724 56,024 27,424
asyncnet 55,720 28,724 56,016 27,412
asyncdispatch 55,584 28,724 55,864 27,356
rdstdin 50,352 28,728 50,056 24,996
linenoise 49,272 28,728 48,856 24,500
httpserver 47,936 24,628 47,752 23,652
net 47,664 24,628 47,432 23,580
scgi 47,384 24,628 47,144 23,424
asyncio 46,992 24,628 46,712 23,248
sockets 46,856 24,628 46,560 23,204
xmldomparser 42,144 24,628 46,224 22,336
distros 40,424 24,628 40,264 20,068
cgi 40,048 24,628 40,048 20,072
xmlparser 35,872 20,532 39,872 19,416
htmlparser 35,872 20,532 39,872 19,404
registry 35,728 24,628 39,664 19,768
browsers 35,584 20,532 39,560 19,292
osproc 35,448 20,532 39,408 19,236
rawsockets 35,408 20,532 39,344 19,284
prelude 35,312 20,532 39,256 19,180
nativesockets 35,264 20,532 39,184 19,228
marshal 35,184 20,532 39,144 18,948
xmltree 35,176 20,532 39,112 19,132
selectors 35,176 20,532 39,112 19,124
terminal 35,152 20,532 39,072 19,148
mimetypes 35,056 20,532 38,968 19,064
cookies 35,048 20,532 38,968 19,056
cpuload 35,040 20,532 38,960 19,052
ssl 35,032 20,532 38,952 19,052
gentabs 34,912 20,532 38,816 19,016
cpuinfo 34,904 20,532 38,816 19,008
json 34,776 20,532 38,688 18,772
segfaults 34,800 20,532 38,680 19,224
ioselectors 34,792 20,532 38,680 18,948
encodings 34,784 20,532 38,672 18,948
parseopt 34,784 20,532 38,672 18,940
memfiles 34,784 20,532 38,672 18,932
winlean 34,784 20,532 38,656 19,188
os 34,640 20,532 38,520 18,884
parsecfg 34,512 20,532 38,408 18,668
parsexml 34,520 20,532 38,408 18,664
basic3d 34,432 20,532 38,280 18,932
parsesql 34,384 20,532 38,256 18,608
openssl 34,368 20,532 38,248 18,620
oids 34,336 20,532 38,200 18,632
db_odbc 34,304 20,532 38,168 18,600
db_postgres 34,264 20,532 38,128 18,556
db_sqlite 34,256 20,532 38,120 18,560
sharedtables 34,256 20,532 38,112 18,568
db_mysql 34,248 20,532 38,112 18,560
parsecsv 34,248 20,532 38,112 18,552
httpcore 34,240 20,532 38,104 18,560
termios 34,232 20,532 38,096 18,556
kqueue 34,232 20,532 38,096 18,552
libuv 34,232 20,532 38,088 18,548
re 34,224 20,532 38,088 18,544
basic2d 34,248 20,532 38,080 18,744
random 34,152 20,532 38,008 18,576
sharedstrings 34,128 20,532 37,976 18,500
asyncmacro 34,120 20,532 37,968 18,496
rationals 34,112 20,532 37,960 18,508
punycode 34,112 20,532 37,960 18,504
htmlgen 34,104 20,532 37,960 18,500
tables 34,104 20,532 37,952 18,496
poly 34,104 20,532 37,952 18,492
pegs 34,104 20,532 37,952 18,484
posix 34,096 20,532 37,944 18,508
sets 34,096 20,532 37,944 18,500
ropes 34,016 20,532 37,832 18,840
securehash 33,984 20,532 37,816 18,452
matchers 33,976 20,532 37,816 18,444
parseurl 33,976 20,532 37,816 18,436
ospaths 33,976 20,532 37,808 18,452
hashes 33,968 20,532 37,808 18,448
subexes 33,976 20,532 37,808 18,444
xmldom 33,968 20,532 37,808 18,440
dynlib 33,968 20,532 37,808 18,436
times 33,968 20,532 37,800 18,448
uri 33,960 20,532 37,800 18,440
strutils 33,840 20,532 37,656 18,400
unidecode 33,792 20,532 37,584 18,512
strscans 33,704 20,532 37,512 18,336
future 33,600 20,532 37,392 18,308
options 33,568 20,532 37,360 18,280
sharedlist 33,560 20,532 37,352 18,280
complex 33,552 20,532 37,344 18,268
stats 33,544 20,532 37,336 18,284
queues 33,544 20,532 37,336 18,280
joyent_http_parser 33,456 20,532 37,232 18,220
oswalkdir 33,424 20,532 37,208 18,220
parseutils 33,432 20,532 37,208 18,216
db_common 33,424 20,532 37,208 18,212
heapqueue 33,424 20,532 37,208 18,208
bitops 33,416 20,532 37,200 18,228
libsvm 33,416 20,532 37,200 18,224
unsigned 33,424 20,532 37,200 18,220
sqlite3 33,424 20,532 37,200 18,216
odbcsql 33,424 20,532 37,200 18,212
pcre 33,416 20,532 37,192 18,220
tinyc 33,416 20,532 37,192 18,216
math 33,416 20,532 37,192 18,212
iup 33,408 20,532 37,192 18,208
__none__ 33,288 20,532 37,048 18,128
#!/bin/sh
nimLibDir=/usr/local/lib/nim
nimCmd='nim c --verbosity:0 --d:release --opt:size --deadcodeElim:on'
get_size_bytes() {
/usr/bin/printf "%'.f\n" $(stat -c %s $1)
}
show_nim_binary_size() {
local tmpBin=/tmp/test
local tmpSrc=$tmpBin.nim
echo '{.deadCodeElim: on.}' > $tmpSrc
echo 'echo "Hello Void"' >> $tmpSrc
local modName=__none__
if [ -n "$1" ]; then
echo "import $1" >> $tmpSrc
modName=$1
fi
rm -f $tmpBin
$nimCmd --cc:gcc --out:$tmpBin $tmpSrc 2>&1 >/dev/null
[ -f "$tmpBin" ] || return
local gccBytes=$(get_size_bytes $tmpBin)
upx -9qqq --ultra-brute $tmpBin
local gccUpxBytes=$(get_size_bytes $tmpBin)
rm -f $tmpBin
$nimCmd --cc:clang --out:$tmpBin $tmpSrc 2>&1 >/dev/null
[ -f "$tmpBin" ] || return
local clangBytes=$(get_size_bytes $tmpBin)
upx -9qqq --ultra-brute $tmpBin
local clangUpxBytes=$(get_size_bytes $tmpBin)
printf "%-16s %11s%11s %11s%11s\n" \
$modName $gccBytes $gccUpxBytes $clangBytes $clangUpxBytes
}
printf "%-16s %11s%11s %11s%11s\n" \
"MODULE:" "GCC BYTES:" "GCC UPX:" "CLANG:" "CLANG UPX:"
show_nim_binary_size
for modFile in $(find $nimLibDir -type f -iname \*.nim)
do
mod=$(basename $modFile | sed 's/\..*//')
show_nim_binary_size $mod $compiler
done
## I used this command for cleaning up output:
## grep -v 'nim(' nimBinSizeTest.output | sort -urk4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment