Skip to content

Instantly share code, notes, and snippets.

View donovanhide's full-sized avatar

Donovan Hide donovanhide

View GitHub Profile
@donovanhide
donovanhide / Merge sort benchmarks
Created January 16, 2013 12:44
sort.Interface compatible merge sort
go test -bench=.
PASS
BenchmarkSortString1K 5000 386508 ns/op
BenchmarkSortInt1K 10000 194999 ns/op
BenchmarkSortInt64K 100 19355025 ns/op
ok _/usr/local/code/timsort 9.003s
go test -run=TestSortBM
PASS
ok _/usr/local/code/timsort 0.607s
@donovanhide
donovanhide / Benchmark
Last active December 11, 2015 01:29
Test to see if copy and pasted sort routine is faster than sort.Sort using interfaces
go test -bench=.*
testing: warning: no tests to run
PASS
BenchmarkSort 5000000 707 ns/op
BenchmarkShellSort 5000000 603 ns/op
@donovanhide
donovanhide / Disassembly
Created January 13, 2013 12:34
Overhead of interfaces with sort.Sort
go tool 6g -S test.go
--- prog list "InvertedSlice.Len" ---
0000 (test.go:17) TEXT InvertedSlice.Len+0(SB),$0-32
0001 (test.go:17) MOVQ s+8(FP),BX
0002 (test.go:17) MOVQ BX,.noname+24(FP)
0003 (test.go:17) RET ,
--- prog list "InvertedSlice.Swap" ---
0004 (test.go:18) TEXT InvertedSlice.Swap+0(SB),$0-40
@donovanhide
donovanhide / Concurrent map benchmarks
Last active January 24, 2016 03:21
Benchmarks for different implementations of a concurrent map
To benchmark:
go test -bench=".*" > machine_description.txt
@donovanhide
donovanhide / testing.go.diff
Last active December 10, 2015 18:28
Patch for testing.go to align multi-line log output of tests. Makes it easier to read and copy and paste
--- a/src/pkg/testing/testing.go Sun Dec 30 12:01:53 2012 -0500
+++ b/src/pkg/testing/testing.go Mon Jan 07 11:43:25 2013 +0000
@@ -91,6 +91,7 @@
"strings"
"sync"
"time"
+ "unicode/utf8"
)
var (
$ go version && go run test.go
go version devel +87f67aadaed6 Sat Dec 22 17:41:00 2012 -0800 darwin/amd64
Test1: 0
Test1: 0
Test1: 0
Test1: 0
Test1: 0
Test1: 0
Test1: 0
Test1: 0
@donovanhide
donovanhide / Benchmark Results
Created December 15, 2012 17:21
First attempt at fast summing of a slice of uint8 using SSE assembly
go test sum -v -benchtime=0.1s
=== RUN TestSmallSumBytes
--- PASS: TestSmallSumBytes (0.00 seconds)
=== RUN TestSumBytes
--- PASS: TestSumBytes (2.52 seconds)
=== RUN TestBenchmark
--- PASS: TestBenchmark (10.96 seconds)
sum_test.go:75: Benchmark Results
Length: 0 Fast: 5.42 ns/op Slow: 4.93 ns/op Improvement -9.03%
Length: 1 Fast: 7.56 ns/op Slow: 5.26 ns/op Improvement -30.39%
$ gcc dht.cc -lstdc++ -o dht && ./dht
PASS
PASS
PASS
PASS
PASS
PASS
PASS
@donovanhide
donovanhide / index.html
Created March 20, 2012 13:35
IP Location Tesseract
<html>
<head>
<title>Streamgraph</title>
<script type="text/javascript" src="http://vis.stanford.edu/protovis/protovis-r3.2.js"></script>
<script type="text/javascript" src="stream.js"></script>
<style type="text/css">
body {
margin: 0;
}
{
"success" : true,
"documents" :{
"metaData" :{
"fields" : ["characters","docid","doctype","fragment_count","group","title"]
},
"rows" :[
{
"fragments" : [[93,11,36,450491776]],
"characters": 993759,