From 2e3388800d028fee3e2b9cf6cfca2c878b7e6327 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Thu, 12 Nov 2015 21:18:18 +0100 Subject: [PATCH] tests: replace linux kernel untar test with synthetic small file creation --- integration_tests/performance_test.go | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/integration_tests/performance_test.go b/integration_tests/performance_test.go index e4a618a..7667243 100644 --- a/integration_tests/performance_test.go +++ b/integration_tests/performance_test.go @@ -1,8 +1,8 @@ package integration_tests import ( + "io/ioutil" "os" - "os/exec" "fmt" "io" "testing" @@ -75,14 +75,25 @@ func BenchmarkStreamRead(t *testing.B) { file.Close() } -func BenchmarkUntar(t *testing.B) { - t.SetBytes(422229778) - c := exec.Command("tar", "xf", "/tmp/linux-3.0.tar.gz", "-C", plainDir) - c.Stdout = os.Stdout - c.Stderr = os.Stderr - t.ResetTimer() - err := c.Run() +func BenchmarkCreate10B(t *testing.B) { + dir := plainDir + "BenchmarkCreate10B" + err := os.RemoveAll(dir) if err != nil { t.Fatal(err) } + err = os.Mkdir(dir, 0777) + if err != nil { + t.Fatal(err) + } + buf := []byte("1234567890") + t.SetBytes(int64(len(buf))) + t.ResetTimer() + var i int + for i = 0; i < t.N; i++ { + file := fmt.Sprintf("%s/%d", dir, i) + err = ioutil.WriteFile(file, buf, 0666) + if err != nil { + t.Fatal(err) + } + } }