All Projects → felixge → Go Xxd

felixge / Go Xxd

Licence: mit
The history of this repo demonstrates how to take a slow xxd implementation in Go, and make it faster than the native version on OSX/Linux.

Programming Languages

go
31211 projects - #10 most used programming language

go-xxd

This repository contains my answer to How can I improve the performance of my xxd port? on reddit.

The result is a Go version of xxd that outperforms the native versions on OSX 10.10.1 / Ubuntu 14.04 (inside VirtualBox), see benchmarks below. However, that is not impressive, given that none of the usual xxd flags are supported.

What is interesting however, are the steps to get there:

You can also follow along by looking at the commit history: https://github.com/felixge/go-xxd/commits/master

OSX 10.10.1:

xxd native:

$ time xxd image.jpg > /dev/null

real	0m0.205s
user	0m0.202s
sys	0m0.003s

xxd.go (original version from reddit):

$ go build xxd.go && time ./xxd image.jpg > /dev/null

real	0m5.914s
user	0m3.598s
sys	0m2.318s

xxd.go (optimized):

$ go build xxd.go && time ./xxd image.jpg > /dev/null

real	0m0.138s
user	0m0.133s
sys	0m0.004s

Ubuntu 14.04 (inside VirtualBox):

xxd native:

$ time xxd image.jpg > /dev/null

real	0m0.273s
user	0m0.017s
sys	0m0.231s

xxd.go (original version from reddit):

$ go build xxd.go && time ./xxd image.jpg > /dev/null

real	0m5.856s
user	0m3.517s
sys	0m1.897s

xxd.go (optimized):

$ go build xxd.go && time ./xxd image.jpg > /dev/null

real	0m0.233s
user	0m0.021s
sys	0m0.207s
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].