Skip to content

Comparing the symbol set and file size impact between two similar programs where one uses fmt and the other os.

License

Notifications You must be signed in to change notification settings

allingeek/fmt-vs-os

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fmt-vs-os

I loved an article I read the other day by a CockroachDB engineer, Why are my Go executable files so large?. I found myself wondering how much smaller we could make a Hello World application just by writing direct to os.Stdout instead of using the fmt package. So today I put together a little experiment using similar methods as those described in the article.

This little project compares to tiny Hello World apps and inspects the resulting programs.

Clone the repo and run ./compare.sh to build and execute the comparison.

Results

Just in case you don't feel like running arbitrary code you found on the internet the output as of today on a macbook running Go 1.12 are as follows:

Symbol counts: fmt 3514, os 1878
fmt has 87.00% more symbols
Hello, World file sizes: fmt 2056k, os 1360k
fmt is 51.00% larger on disk

About

Comparing the symbol set and file size impact between two similar programs where one uses fmt and the other os.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published