Skip to content

Commit

Permalink
Merge pull request #397 from mozilla-services/347-omnija-benchmark
Browse files Browse the repository at this point in the history
347 omnija benchmark
  • Loading branch information
g-k committed Nov 4, 2019
2 parents 44e9846 + 6e1d289 commit 2530d5e
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions .dockerignore
@@ -0,0 +1 @@
signer/xpi/test/fixtures
13 changes: 13 additions & 0 deletions Makefile
Expand Up @@ -81,6 +81,19 @@ ifeq ($(RACE_TEST),1)
$(GO) test -v -race $(PACKAGE_PATH)
endif

benchmarkxpi:
benchmark%: PACKAGE_NAME = $(subst benchmark,,$@)
benchmark%: PACKAGE_PATH = $(addprefix go.mozilla.org/autograph/signer/,$(subst benchmark,,$@))
benchmark%: PACKAGE_TEST_OUTPUT_DIR = $(subst benchmark,testprofiles/,$@)
benchmark%:
mkdir -p $(PACKAGE_TEST_OUTPUT_DIR)
$(GO) test -run=XXX -benchtime=15s -bench=. -v -cpuprofile "testprofiles/$(PACKAGE_NAME)/cpu.out" $(PACKAGE_PATH)

showbenchmarkxpi:
showbenchmark%: PACKAGE_NAME = $(subst showbenchmark,,$@)
showbenchmark%:
go tool pprof -web "testprofiles/$(PACKAGE_NAME)/cpu.out"

showcoverageautograph:
showcoveragedatabase:
showcoverageformats:
Expand Down
59 changes: 59 additions & 0 deletions signer/xpi/omnija_bench_test.go
@@ -0,0 +1,59 @@
package xpi

import (
"io/ioutil"
"testing"
"time"

"go.mozilla.org/autograph/signer"
)

func BenchmarkResignOmnija(b *testing.B) {
var (
err error = nil
omnijaBytes, browserOmnijaBytes []byte
)

omnijaBytes, err = ioutil.ReadFile("test/fixtures/firefox-70.0.1/omni.ja")
if err != nil {
b.Fatalf("failed to read omni.ja test file with: %s", err)
}
browserOmnijaBytes, err = ioutil.ReadFile("test/fixtures/firefox-70.0.1/browser/omni.ja")
if err != nil {
b.Fatalf("failed to read omni.ja test file with: %s", err)
}

// initialize a system addon signer with an RSA key
testcase := PASSINGTESTCASES[1]

// don't use an RSA key cache
testcase.RSACacheConfig = signer.RSACacheConfig{
NumKeys: 0,
NumGenerators: 0,
GeneratorSleepDuration: 10 * time.Minute,
FetchTimeout: 0,
StatsSampleRate: 10 * time.Minute,
}

s, err := New(testcase, nil)
if err != nil {
b.Fatalf("signer initialization failed with: %v", err)
}
signOptions := Options{
ID: "omnija+benchmark@mozilla.com",
COSEAlgorithms: []string{"ES256"},
PKCS7Digest: "SHA256",
}

for n := 0; n < b.N; n++ {
// sign both omni.ja files once
_, err = s.SignFile(omnijaBytes, signOptions)
if err != nil {
b.Fatalf("failed to sign omni.ja: %v", err)
}
_, err = s.SignFile(browserOmnijaBytes, signOptions)
if err != nil {
b.Fatalf("failed to sign browser/omni.ja: %v", err)
}
}
}
Binary file not shown.
Binary file added signer/xpi/test/fixtures/firefox-70.0.1/omni.ja
Binary file not shown.

0 comments on commit 2530d5e

Please sign in to comment.