Skip to content

Commit

Permalink
Tweak benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
klauspost committed Feb 14, 2023
1 parent b214753 commit 0751108
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions s2/lz4convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ import (
func TestLZ4Converter_ConvertBlock(t *testing.T) {
for _, tf := range testFiles {
t.Run(tf.label, func(t *testing.T) {

if err := downloadBenchmarkFiles(t, tf.filename); err != nil {
t.Fatalf("failed to download testdata: %s", err)
}

bDir := filepath.FromSlash(*benchdataDir)
data := readFile(t, filepath.Join(bDir, tf.filename))
if n := tf.sizeLimit; 0 < n && n < len(data) {
data = data[:n]
}

lz4Data := make([]byte, lz4ref.CompressBlockBound(len(data)))
n, err := lz4ref.CompressBlock(data, lz4Data)
if err != nil {
Expand Down Expand Up @@ -82,8 +86,13 @@ func BenchmarkLZ4Converter_ConvertBlock(b *testing.B) {
if err := downloadBenchmarkFiles(b, tf.filename); err != nil {
b.Fatalf("failed to download testdata: %s", err)
}

bDir := filepath.FromSlash(*benchdataDir)
data := readFile(b, filepath.Join(bDir, tf.filename))
if n := tf.sizeLimit; 0 < n && n < len(data) {
data = data[:n]
}

lz4Data := make([]byte, lz4ref.CompressBlockBound(len(data)))
n, err := lz4ref.CompressBlock(data, lz4Data)
if err != nil {
Expand Down Expand Up @@ -116,14 +125,18 @@ func BenchmarkLZ4Converter_ConvertBlock(b *testing.B) {
}

func BenchmarkCompressBlockReference(b *testing.B) {
b.Skip("Only reference for BenchmarkLZ4Converter_ConvertBlock")
//b.Skip("Only reference for BenchmarkLZ4Converter_ConvertBlock")
for _, tf := range testFiles {
b.Run(tf.label, func(b *testing.B) {
if err := downloadBenchmarkFiles(b, tf.filename); err != nil {
b.Fatalf("failed to download testdata: %s", err)
}
bDir := filepath.FromSlash(*benchdataDir)
data := readFile(b, filepath.Join(bDir, tf.filename))
if n := tf.sizeLimit; 0 < n && n < len(data) {
data = data[:n]
}

lz4Data := make([]byte, lz4ref.CompressBlockBound(len(data)))
n, err := lz4ref.CompressBlock(data, lz4Data)
if err != nil {
Expand Down

0 comments on commit 0751108

Please sign in to comment.