Skip to content

Instantly share code, notes, and snippets.

@qianbin
Last active August 6, 2022 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qianbin/bffcd248b7312c35d7d526a974018b1b to your computer and use it in GitHub Desktop.
Save qianbin/bffcd248b7312c35d7d526a974018b1b to your computer and use it in GitHub Desktop.
full nodes compression ratio
func main() {
var node [16][]byte
for i := 0; i < len(node); i++ {
b := make([]byte, 32)
rand.Read(b)
node[i] = b
}
buf := bytes.NewBuffer(nil)
for i := 0; i < 100; i++ {
rlp.Encode(buf, node)
src := buf.Bytes()
enc := snappy.Encode(nil, src)
fmt.Println("n =", i+1, "src = ", len(src), "enc = ", len(enc), "r = ", float64(len(enc))/float64(len(src)))
rand.Read(node[rand.Intn(len(node))])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment