File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,13 +23,35 @@ import (
2323 "io"
2424 "io/ioutil"
2525 "math/rand"
26+ "net/http"
2627 "os"
2728 "os/exec"
2829 "path/filepath"
2930 "runtime"
3031 "testing"
3132)
3233
34+ const benchmarkTestDataURL = "https://git.io/fADcl"
35+
36+ var benchmarkTestData []byte
37+
38+ func TestMain (m * testing.M ) {
39+ // Download test data for benchmark from gist
40+ resp , err := http .Get (benchmarkTestDataURL )
41+ if err != nil {
42+ panic (err )
43+ }
44+
45+ defer resp .Body .Close ()
46+
47+ benchmarkTestData , err = ioutil .ReadAll (resp .Body )
48+ if err != nil {
49+ panic (err )
50+ }
51+
52+ os .Exit (m .Run ())
53+ }
54+
3355// generateData generates data that composed of 2 random parts
3456// and single zero-filled part within them.
3557// Typically, the compression ratio would be about 67%.
@@ -184,7 +206,7 @@ func TestCmdStreamBad(t *testing.T) {
184206
185207func generateCompressedData (b * testing.B , sizeInMb int ) []byte {
186208 sizeInBytes := sizeInMb * 1024 * 1024
187- data , _ := ioutil . ReadFile ( "testdata/test.json" )
209+ data := benchmarkTestData
188210
189211 for len (data ) < sizeInBytes {
190212 data = append (data , data ... )
You can’t perform that action at this time.
0 commit comments