Skip to content

Commit

Permalink
add e2e benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
ybirader committed Sep 6, 2023
1 parent 909040f commit 836f4f4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
todos.txt
bechmarks.txt
benchmarks.txt
benchmark
2 changes: 1 addition & 1 deletion archiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,6 @@ func BenchmarkArchive(b *testing.B) {
b.ResetTimer()

for i := 0; i < b.N; i++ {
archiver.Archive(context.Background(), []string{helloTxtFileFixture, helloMarkdownFileFixture})
archiver.Archive(context.Background(), []string{helloDirectoryFixture})
}
}
36 changes: 33 additions & 3 deletions cmd/cli/pzip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ import (
)

const (
testdataRoot = "../../testdata"
archivePath = testdataRoot + "/archive.zip"
dirPath = testdataRoot + "/hello"
testdataRoot = "../../testdata"
archivePath = testdataRoot + "/archive.zip"
dirPath = testdataRoot + "/hello"
benchmarkRoot = testdataRoot + "/benchmark"
benchmarkDirPath = benchmarkRoot + "/bench"
benchmarkArchivePath = benchmarkRoot + "/bench.zip"
)

func TestPzip(t *testing.T) {
Expand Down Expand Up @@ -40,3 +43,30 @@ func TestPzip(t *testing.T) {

specifications.ArchiveDir(t, driver)
}

func BenchmarkPzip(b *testing.B) {
binPath, cleanup, err := cli.BuildBinary()
if err != nil {
log.Fatal("ERROR: could not build binary", err)
}
defer cleanup()

absArchivePath, err := filepath.Abs(benchmarkArchivePath)
if err != nil {
b.Fatalf("ERROR: could not get path to archive %s", benchmarkArchivePath)
}

absDirPath, err := filepath.Abs(benchmarkDirPath)
if err != nil {
b.Fatalf("ERROR: could not get path to directory %s", benchmarkDirPath)
}

driver := cli.NewDriver(binPath, absArchivePath, absDirPath)

b.ReportAllocs()
b.ResetTimer()

for i := 0; i < b.N; i++ {
driver.Archive()
}
}

0 comments on commit 836f4f4

Please sign in to comment.