Skip to content

Instantly share code, notes, and snippets.

View extemporalgenome's full-sized avatar

Kevin Gillette extemporalgenome

  • Twilio SendGrid
  • Denver, CO
View GitHub Profile
Tested on:
Linux 3.12-1-amd64 #1 SMP Debian 3.12.9-1 (2014-02-01) x86_64 GNU/Linux
[Dual Core] Intel(R) Atom(TM) CPU N450 @ 1.66GHz
(below output manually aligned)
Array#sort x 100,884 ops/sec ±1.54% (87 runs sampled)
mout/array/sort x 28,408 ops/sec ±1.98% (89 runs sampled)
nativeStableSort x 30,591 ops/sec ±4.26% (81 runs sampled)
nativeInPlaceStableSort x 66,010 ops/sec ±2.15% (97 runs sampled)
package main
import "strconv"
func main() {
println(strconv.Itoa(5))
}
#!/bin/sh
if [ $# -eq 0 ]; then
echo this script works when you run it without args
exit 0
fi
# the parser only reaches this syntactically-invalid line if you pass the script args,
# proving that Bourne-compatible shells don't have separate parse and evaluate passes.
esac ] $(`)"
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
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)
@extemporalgenome
extemporalgenome / analyze.go
Last active December 11, 2015 16:38
Odd behavior of golang's sort.Sort implementation.
package main
import (
"github.com/extemporalgenome/sortutil"
"os"
"sort"
)
func main() {
sortutil.Analyze(os.Stdout, true, sort.Sort)
@extemporalgenome
extemporalgenome / 5-or-more-dups.txt
Last active December 17, 2015 12:48
godoc.org table of basename duplicates (grouped by number of duplicates)
57 config
48 util
37 client
32 log
28 web
27 server
26 cache
25 model
23 core
23 redis
@extemporalgenome
extemporalgenome / copy_test.go
Created November 25, 2013 00:18
go copy bench
package main
import (
"testing"
"unsafe"
)
const N = 32 << 20 // 32 MiB
type struct32 struct {
@extemporalgenome
extemporalgenome / Main.elm
Last active April 14, 2022 15:00
Comparing modulo arithmetic across languages
-- https://en.wikipedia.org/wiki/Modular_arithmetic#Examples
-- https://ellie-app.com/hd32NnLQSFqa1
-- Output:
-- 38 ≡ 14 (flooring mod 12)
-- 2 ≢ -3 (flooring mod 5)
-- -8 ≢ 7 (flooring mod 5)
-- -3 ≢ -8 (flooring mod 5)
--
-- 38 ≡ 14 (truncating mod 12)
-- 2 ≢ -3 (truncating mod 5)