Skip to content

Instantly share code, notes, and snippets.

View extemporalgenome's full-sized avatar

Kevin Gillette extemporalgenome

  • Twilio Segment
  • Denver, CO
  • 19:24 (UTC -07:00)
View GitHub Profile
For whatever reason, at least with amd64 tests builds on my AMD X2 3800+,
the pointer receiver implementation is 13% slower when bound checks are elided.
# default run (value receiver is 49% slower than ptr receiver)
go test -bench .
BenchmarkSortVal 1000000 1300 ns/op
BenchmarkSortPtrToVal 1000000 1297 ns/op
BenchmarkSortPtr 2000000 870 ns/op
# no bounds checking (value receiver is 11% slower than ptr receiver)
def hex_buffer(buf):
retstr=''.join(map(lambda c:'\\x%02x'%ord(c),buf))
retstr="E'"+retstr+"'"
return retstr
def hex_buffer(buf):
retstr=''.join(map(lambda c:'\\x%02x'%ord(c),buf))
retstr="E'"+retstr+"'"
return retstr