Skip to content

Commit

Permalink
Use tempfile.
Browse files Browse the repository at this point in the history
  • Loading branch information
notbdu committed Feb 8, 2019
1 parent 3f78f93 commit 89a226b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions values/encoding/compression_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,23 @@ import (
)

const (
testDataFilePath = "./testdata/testdata.json"
compressedDataFilePath = "../decoding/testdata/testdata.json.compressed"
testDataFilePath = "./testdata/testdata.json"
)

func compressData(data []byte) error {
out, err := os.OpenFile(compressedDataFilePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
out, err := ioutil.TempFile("/tmp", "*")
if err != nil {
return err
}
defer out.Close()
defer os.Remove(out.Name())

writer := gozstd.NewWriter(out)
_, err = writer.Write(data)
defer writer.Close()
if err != nil {
return err
}
defer writer.Release()
return err
return writer.Close()
}

// Benchmark compression results:
Expand Down

0 comments on commit 89a226b

Please sign in to comment.