Skip to content

Commit

Permalink
mw_jwt benchmarks added, existing benchmarks fixed (TykTechnologies#1509
Browse files Browse the repository at this point in the history
)

added more benchmarking instrumentation

- started with `mw_jwt`
- added `utils/ci-benchmark.sh` which just runs benchmarking and has optional parameter - regex for benchmarks to run
- travis will run it but it will just produce numbers - no performance/memory allocation asserts there
  • Loading branch information
dencoded authored and buger committed Mar 8, 2018
1 parent 4d0bce9 commit b67766a
Show file tree
Hide file tree
Showing 7 changed files with 233 additions and 124 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ script:
- go build -tags 'coprocess grpc'
- ./utils/ci-test.sh
- if [[ $LATEST_GO ]]; then goveralls -coverprofile=<(gocovmerge *.cov); fi
- ./utils/ci-benchmark.sh
11 changes: 6 additions & 5 deletions api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -724,13 +724,14 @@ func TestHotReloadMany(t *testing.T) {
}

func BenchmarkApiReload(b *testing.B) {
specs := make([]*APISpec, 1000)
b.ReportAllocs()

for i := 0; i < 1000; i++ {
s := buildAndLoadAPI(func(spec *APISpec) {
specs := make([]*APISpec, 100)

for i := 0; i < 100; i++ {
specs[i] = buildAndLoadAPI(func(spec *APISpec) {
spec.APIID = strconv.Itoa(i + 1)
})
specs = append(specs, s[0])
})[0]
}

b.ResetTimer()
Expand Down
2 changes: 1 addition & 1 deletion gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func createSpecTest(t *testing.T, def string) *APISpec {
return spec
}

func testKey(t *testing.T, name string) string {
func testKey(t testing.TB, name string) string {
return fmt.Sprintf("%s-%s", t.Name(), name)
}

Expand Down
2 changes: 1 addition & 1 deletion helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func (s *tykTestServer) Do(tc test.TestCase) (*http.Response, error) {
return tc.Client.Do(req)
}

func (s *tykTestServer) Run(t *testing.T, testCases ...test.TestCase) (*http.Response, error) {
func (s *tykTestServer) Run(t testing.TB, testCases ...test.TestCase) (*http.Response, error) {
var lastResponse *http.Response
var lastError error

Expand Down
Loading

0 comments on commit b67766a

Please sign in to comment.