case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
return val.Uint() == 0
}
- panic("unknown type in isZero" + val.Type().String())
+ panic("unknown type in isZero " + val.Type().String())
}
// encGobEncoder encodes a value that implements the GobEncoder interface.
var buf bytes.Buffer
enc := NewEncoder(&buf)
bench := &Bench{7, 3.2, "now is the time", []byte("for all good men")}
+ runtime.UpdateMemStats()
mallocs := 0 - runtime.MemStats.Mallocs
const count = 1000
for i := 0; i < count; i++ {
t.Fatal("encode:", err)
}
}
+ runtime.UpdateMemStats()
mallocs += runtime.MemStats.Mallocs
fmt.Printf("mallocs per encode of type Bench: %d\n", mallocs/count)
}
}
}
dec := NewDecoder(&buf)
+ runtime.UpdateMemStats()
mallocs := 0 - runtime.MemStats.Mallocs
for i := 0; i < count; i++ {
*bench = Bench{}
t.Fatal("decode:", err)
}
}
+ runtime.UpdateMemStats()
mallocs += runtime.MemStats.Mallocs
fmt.Printf("mallocs per decode of type Bench: %d\n", mallocs/count)
}