mirror of https://github.com/schollz/croc.git
remove big file after testing
This commit is contained in:
parent
bcb348a776
commit
6b288356b9
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func bigFile() {
|
||||||
rand.Seed(0)
|
rand.Seed(0)
|
||||||
bigBuff := make([]byte, 75000000)
|
bigBuff := make([]byte, 75000000)
|
||||||
rand.Read(bigBuff)
|
rand.Read(bigBuff)
|
||||||
|
@ -18,41 +18,55 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkMD5(b *testing.B) {
|
func BenchmarkMD5(b *testing.B) {
|
||||||
|
bigFile()
|
||||||
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
MD5HashFile("bigfile.test")
|
MD5HashFile("bigfile.test")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkXXHash(b *testing.B) {
|
func BenchmarkXXHash(b *testing.B) {
|
||||||
|
bigFile()
|
||||||
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
XXHashFile("bigfile.test")
|
XXHashFile("bigfile.test")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func BenchmarkImoHash(b *testing.B) {
|
func BenchmarkImoHash(b *testing.B) {
|
||||||
|
bigFile()
|
||||||
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
IMOHashFile("bigfile.test")
|
IMOHashFile("bigfile.test")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestExists(t *testing.T) {
|
func TestExists(t *testing.T) {
|
||||||
|
bigFile()
|
||||||
|
defer os.Remove("bigfile.test")
|
||||||
fmt.Println(GetLocalIPs())
|
fmt.Println(GetLocalIPs())
|
||||||
assert.True(t, Exists("bigfile.test"))
|
assert.True(t, Exists("bigfile.test"))
|
||||||
assert.False(t, Exists("doesnotexist"))
|
assert.False(t, Exists("doesnotexist"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMD5HashFile(t *testing.T) {
|
func TestMD5HashFile(t *testing.T) {
|
||||||
|
bigFile()
|
||||||
|
defer os.Remove("bigfile.test")
|
||||||
b, err := MD5HashFile("bigfile.test")
|
b, err := MD5HashFile("bigfile.test")
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, "9fed05acbacbc6a36555c998501c21f6", fmt.Sprintf("%x", b))
|
assert.Equal(t, "9fed05acbacbc6a36555c998501c21f6", fmt.Sprintf("%x", b))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIMOHashFile(t *testing.T) {
|
func TestIMOHashFile(t *testing.T) {
|
||||||
|
bigFile()
|
||||||
|
defer os.Remove("bigfile.test")
|
||||||
b, err := IMOHashFile("bigfile.test")
|
b, err := IMOHashFile("bigfile.test")
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, "c0d1e123a96a598ea801cc503d3db8c0", fmt.Sprintf("%x", b))
|
assert.Equal(t, "c0d1e123a96a598ea801cc503d3db8c0", fmt.Sprintf("%x", b))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestXXHashFile(t *testing.T) {
|
func TestXXHashFile(t *testing.T) {
|
||||||
|
bigFile()
|
||||||
|
defer os.Remove("bigfile.test")
|
||||||
b, err := XXHashFile("bigfile.test")
|
b, err := XXHashFile("bigfile.test")
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, "f2da6ee7e75e8324", fmt.Sprintf("%x", b))
|
assert.Equal(t, "f2da6ee7e75e8324", fmt.Sprintf("%x", b))
|
||||||
|
|
Loading…
Reference in New Issue