Skip to content
forked from felixge/go-xxd

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.

License

Notifications You must be signed in to change notification settings

aphroteus/go-xxd

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%