Move compression benchmark test data to gist
Signed-off-by: Maksym Pavlenko <makpav@amazon.com>
This commit is contained in:
parent
4d7d63f390
commit
003b27eff4
@ -23,6 +23,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -30,6 +31,27 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const benchmarkTestDataURL = "https://git.io/fADcl"
|
||||||
|
|
||||||
|
var benchmarkTestData []byte
|
||||||
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
// Download test data for benchmark from gist
|
||||||
|
resp, err := http.Get(benchmarkTestDataURL)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
benchmarkTestData, err = ioutil.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
os.Exit(m.Run())
|
||||||
|
}
|
||||||
|
|
||||||
// generateData generates data that composed of 2 random parts
|
// generateData generates data that composed of 2 random parts
|
||||||
// and single zero-filled part within them.
|
// and single zero-filled part within them.
|
||||||
// Typically, the compression ratio would be about 67%.
|
// Typically, the compression ratio would be about 67%.
|
||||||
@ -184,7 +206,7 @@ func TestCmdStreamBad(t *testing.T) {
|
|||||||
|
|
||||||
func generateCompressedData(b *testing.B, sizeInMb int) []byte {
|
func generateCompressedData(b *testing.B, sizeInMb int) []byte {
|
||||||
sizeInBytes := sizeInMb * 1024 * 1024
|
sizeInBytes := sizeInMb * 1024 * 1024
|
||||||
data, _ := ioutil.ReadFile("testdata/test.json")
|
data := benchmarkTestData
|
||||||
|
|
||||||
for len(data) < sizeInBytes {
|
for len(data) < sizeInBytes {
|
||||||
data = append(data, data...)
|
data = append(data, data...)
|
||||||
|
5902
archive/compression/testdata/test.json
vendored
5902
archive/compression/testdata/test.json
vendored
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user