Ejemplo n.º 1
0
func BenchmarkCompressBlockHC(b *testing.B) {
	d := make([]byte, len(lorem))
	z := make([]byte, len(lorem))
	n, err := lz4.CompressBlockHC(lorem, z, 0)
	if err != nil {
		b.Errorf("CompressBlock: %s", err)
		b.FailNow()
	}
	z = z[:n]
	for i := 0; i < b.N; i++ {
		lz4.CompressBlockHC(z, d, 0)
	}
}
Ejemplo n.º 2
0
func (_ Test) LZ4Compress() {
	var b = []byte("dette er en test af LZ4 komprimering")
	e.InfoLog.Println(string(b))
	b = testData

	var compressed = make([]byte, len(b))
	size, err := lz4.CompressBlockHC(b, compressed, 0)
	if err != nil || size == 0 {
		e.InfoLog.Println(err, size)
	}
	compressed = compressed[:size]

	var out = make([]byte, len(b))
	_, err = lz4.UncompressBlock(compressed, out, 0)
	if err != nil {
		e.InfoLog.Println(err, size)
	}

	e.InfoLog.Println("Result of LZ4 compression: ", len(b), size)
}