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
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) |
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
def hex_buffer(buf): | |
retstr=''.join(map(lambda c:'\\x%02x'%ord(c),buf)) | |
retstr="E'"+retstr+"'" | |
return retstr |
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
def hex_buffer(buf): | |
retstr=''.join(map(lambda c:'\\x%02x'%ord(c),buf)) | |
retstr="E'"+retstr+"'" | |
return retstr |