From 9231b1a661f8f5a7868b76c08e1e68846b152c98 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Sat, 17 Apr 2021 09:39:47 -0700 Subject: [PATCH] update utils benchmark --- src/utils/utils_test.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/utils/utils_test.go b/src/utils/utils_test.go index c133477..e3e2bdf 100644 --- a/src/utils/utils_test.go +++ b/src/utils/utils_test.go @@ -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")