1
0
mirror of https://github.com/schollz/croc.git synced 2024-11-30 23:52:07 +03:00

update utils benchmark

This commit is contained in:
Zack Scholl 2021-04-17 09:39:47 -07:00
parent 3e56d4cdb9
commit 9231b1a661

View File

@ -10,11 +10,14 @@ import (
"strings"
"testing"
"github.com/schollz/croc/v8/src/models"
"github.com/stretchr/testify/assert"
)
var bigFileSize = 75000000
func bigFile() {
ioutil.WriteFile("bigfile.test", bytes.Repeat([]byte("z"), 75000000), 0666)
ioutil.WriteFile("bigfile.test", bytes.Repeat([]byte("z"), bigFileSize), 0666)
}
func BenchmarkMD5(b *testing.B) {
@ -47,6 +50,14 @@ func BenchmarkSha256(b *testing.B) {
}
}
func BenchmarkMissingChunks(b *testing.B) {
bigFile()
b.ResetTimer()
for i := 0; i < b.N; i++ {
MissingChunks("bigfile.test", int64(bigFileSize), models.TCP_BUFFER_SIZE/2)
}
}
func TestExists(t *testing.T) {
bigFile()
defer os.Remove("bigfile.test")