Skip to content

Instantly share code, notes, and snippets.

package bench
import (
"bytes"
"compress/gzip"
ogzip "github.com/klauspost/compress/gzip"
"testing"
)
var bidReq = []byte(`{"id":"50215d10a41d474f77591bff601f6ade","imp":[{"id":"86df3bc6-7bd4-44d9-64e2-584a69790229","native":{"request":"{\"ver\":\"1.0\",\"plcmtcnt\":1,\"assets\":[{\"id\":1,\"data\":{\"type\":12}},{\"id\":2,\"required\":1,\"title\":{\"len\":50}},{\"id\":3,\"required\":1,\"img\":{\"type\":1,\"w\":80,\"h\":80}},{\"id\":4,\"required\":1,\"img\":{\"type\":3,\"w\":1200,\"h\":627}},{\"id\":5,\"data\":{\"type\":3}},{\"id\":6,\"required\":1,\"data\":{\"type\":2,\"len\":100}}]}","ver":"1.0"},"tagid":"1","bidfloor":0.6,"bidfloorcur":"USD"}],"site":{"id":"1012864","domain":"www.abc.com","cat":["IAB3"],"mobile":1,"keywords":"apps,games,discovery,recommendation"},"device":{"dnt":1,"ua":"Mozilla/5.0 (Linux; U; Android 4.2.2; km-kh; SHV-E120S Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30","ip":"175.100.59.170","geo":{"lat":11.5625,"lon":104.916,"country":"KHM","r
//+build ignore
package main
// Adapted from : https://gist.github.com/arnehormann/65421048f56ac108f6b5
import (
"bufio"
"encoding/binary"
"flag"
PASS
BenchmarkShift-4 20000 69666 ns/op 940.71 MB/s
BenchmarkAnd-4 20000 66802 ns/op 981.04 MB/s
ok _/c_/Temp/shifttest 4.146s
PASS
BenchmarkShift-4 20000 68680 ns/op 954.21 MB/s
BenchmarkAnd-4 20000 67339 ns/op 973.21 MB/s
ok _/c_/Temp/shifttest 4.121s
PASS
BenchmarkShift-4 20000 68687 ns/op 954.12 MB/s
@klauspost
klauspost / test.go
Last active January 6, 2016 12:23
filesystem test
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
)
func main() {
//+build !appengine
package prefetch
func prefetchBS(b [][]byte)
@klauspost
klauspost / memmove.go
Created November 23, 2015 13:14
memmove testing harness.
package move
import "unsafe"
func memmove(to uintptr, from uintptr, n uintptr)
func MemMove(dst, src []byte) {
memmove(uintptr(unsafe.Pointer(&dst[0])), uintptr(unsafe.Pointer(&src[0])), uintptr(len(src)))
}
package main
import (
"fmt"
"math/rand"
)
// This will show various cases where bounds checks can be eliminated by keeping track of
// minimum and maximum potential values of slices and variables as SSA.
func main() {
// THESE PACKAGES ARE FOR DEMONSTRATION PURPOSES ONLY!
//
// THEY DO NOT NOT CONTAIN WORKING INTRINSICS!
//
// See https://github.com/klauspost/intrinsics
package sse2
import "github.com/bjwbell/gensimd/simd"
var _ = simd.M128{} // Make sure we use simd package
@klauspost
klauspost / hashtag.go
Created October 13, 2015 09:16
Hashtag identifier & splitter.
// Match tags in notes, etc.
// Group 1: Must start with whitespace OR start of string
// - : Must start with hash sign #
// Group 2: Match everything, until we reach a whitespace, '#' '.' ',' '!' ')'.
// Must be end of string
var matchTags = regexp.MustCompile(`[^\S]|^#([^\s#.,!)]+)$`)
// tagsSplitter returns true if the current rune is a tag ending
// Tags MUST end with whitespace, '.' ',' '!' or ')'
func tagsSplitter(c rune) bool {
@klauspost
klauspost / dictionary-sorted.txt
Last active August 25, 2024 23:18
Brotli dictionary - printed escaped
" </div>"
" })();\r\n"
" && "
" &amp; "
" &nbsp;"
" ''The "
" (&quot;"
" (199"
" (200"
" (e.g."