Skip to content

Instantly share code, notes, and snippets.

@derekcollison
derekcollison / FastGoHash
Created October 21, 2012 17:40
Fast Hash and HashMap in Go
I have really come to enjoy working in Go. From time to time I expect that the team at Apcera will
need to dip back into C for some things, but I decided to try to push the envelope with Go on making
some faster HashMaps than Go's builtin map. I started with the hash algorithms.
These are some results from my MBA11" core i7.. The fastest Hash algorithms will not work on machines
without support for unaligned access, and I still need to do some cleaning up before we OSS, but so far so good.
I aslo need to implement the fastest one, FNV1A_Hash_Yorikke, from http://http://www.sanmayce.com/Fastest_Hash
I hack SetBytes(1) to get a rough idea of ops/sec, its not actually IO.. So 10 MB/s is 10 Million ops per sec.
@jboner
jboner / latency.txt
Last active July 17, 2024 03:12
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@grier
grier / snapshot.java
Created February 13, 2012 07:11
vSphere API - Snapshot.java
public static void doSnapshot(String url, String username, String password, String vmname, String snapshotname) throws Exception
{
ServiceInstance si = new ServiceInstance(new URL(url), username, password, true);
Folder rootFolder = si.getRootFolder();
VirtualMachine vm = null;
vm = (VirtualMachine) new InventoryNavigator(rootFolder).searchManagedEntity("VirtualMachine", vmname);
if(vm==null)
{
@border
border / Makefile
Created January 12, 2011 01:36
json example in golang
include $(GOROOT)/src/Make.inc
GOFMT=gofmt -spaces=true -tabindent=false -tabwidth=4
all:
$(GC) jsontest.go
$(LD) -o jsontest.out jsontest.$O
format:
$(GOFMT) -w jsontest.go