Skip to content

Instantly share code, notes, and snippets.

View rogpeppe's full-sized avatar

Roger Peppe rogpeppe

View GitHub Profile
@rogpeppe
rogpeppe / gist:874010
Created March 17, 2011 08:37
go map/slice/array benchmark
package main
import (
"fmt"
"testing"
)
const Size = 1e6
var (
array [Size]int
package main
import (
"log"
"runtime"
)
func main() {
m := mkmap()
for _ = range m {
package main
import (
"log"
"runtime"
)
func main() {
mkmap()
log.Println("before GC", runtime.MemStats.HeapAlloc)
package main
import (
"fmt"
"runtime"
"testing"
)
func main() {
fmt.Printf("add %v\n", testing.Benchmark(benchAdd))
package main
import (
"log"
"runtime"
)
func main() {
m := mkmap()
for _ = range m {