Skip to content

Instantly share code, notes, and snippets.

@phemmer
phemmer / main_test.go
Last active August 29, 2015 14:20
golang json unmarshal benchmarks
package main
import (
"encoding/json"
"fmt"
"testing"
)
type elements map[string]int
@phemmer
phemmer / main_test.go
Created April 22, 2015 16:20
go bcrypt benchmark
package main
import (
"testing"
"golang.org/x/crypto/bcrypt"
)
func BenchmarkBcrypt4(b *testing.B) {
benchBcrypt(b, 4)
@phemmer
phemmer / main.go
Created April 22, 2015 02:29
golang db scan comparison
package main
import (
"database/sql"
"encoding/json"
"fmt"
_ "github.com/mattn/go-sqlite3"
)
#include <stdlib.h>
#include <stdio.h>
int main() {
char *buf;
int i;
for (i = 0; i < 2048; i++) {
buf = (char *) malloc(1024*1024);
printf("buf=%p\n", buf);
@phemmer
phemmer / callers_test.go
Last active August 29, 2015 14:19
golang callers benchmark
package main
import (
"runtime"
"testing"
)
var callers [100]uintptr
var callersCopy []uintptr
@phemmer
phemmer / 97g.go
Created April 15, 2015 19:41
mysql schema benchmark
// import tmp/97g
package main
import (
"database/sql"
"fmt"
"log"
"math/rand"
"strconv"
"time"
@phemmer
phemmer / lock_test.go
Created April 11, 2015 01:05
golang locking benchmarks
package main
import (
"sync"
"sync/atomic"
"testing"
)
var v int64
@phemmer
phemmer / bench_test.go
Created April 10, 2015 16:31
defer vs no defer
package main
import (
"testing"
)
type conn struct{}
func (c *conn) Close() {}
func (c *conn) Value() bool {
@phemmer
phemmer / bench_test.go
Created February 25, 2015 14:31
string concat benchmark
package main
import (
"fmt"
"testing"
)
const str = "s"
var bslice = []byte(str)
package main
import (
sm "github.com/phemmer/sawmill"
)
type mymap map[string]interface{}
type mystruct struct {
Foo string
Bar string