Created
August 21, 2014 13:11
-
-
Save ardan-bkennedy/6ffc995f65d0ff5ee88c to your computer and use it in GitHub Desktop.
Go Allocation Challenge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Created by Bill Hathaway to see if line 16 would produce an | |
// allocation in Go v1.3 | |
package main | |
import ( | |
"testing" | |
) | |
var ( | |
m = make(map[string]struct{}) | |
ba = []byte{104, 101, 108, 108, 111} | |
) | |
func BenchmarkExternalAllocations(b *testing.B) { | |
for i := 0; i < b.N; i++ { | |
external := string(ba) | |
m[external] = struct{}{} | |
} | |
b.ReportAllocs() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment