Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add benchmarks for client.AddTemplate #159

Merged
merged 3 commits into from
Nov 23, 2021

Conversation

willbeason
Copy link
Member

Add benchmarks for client.AddTemplate for a simple ConstraintTemplate and a complex one. The complex ConstraintTemplate is a copy of UniqueIngressHost. It's okay if this falls out of sync with the ConstraintTemplate it's based on - what matters is having a complex CT, not that it exactly matches one.

constraint$ go test ./pkg/client --bench=. --benchmem
goos: linux
goarch: amd64
pkg: github.com/open-policy-agent/frameworks/constraint/pkg/client
cpu: Intel(R) Xeon(R) W-2135 CPU @ 3.70GHz
BenchmarkClient_AddTemplate/Simple/1_Templates-12         	     129	   9058282 ns/op	 1200880 B/op	   23595 allocs/op
BenchmarkClient_AddTemplate/Simple/2_Templates-12         	      61	  17941913 ns/op	 2379309 B/op	   47185 allocs/op
BenchmarkClient_AddTemplate/Simple/5_Templates-12         	      25	  46099557 ns/op	 5940319 B/op	  117951 allocs/op
BenchmarkClient_AddTemplate/Simple/10_Templates-12        	      12	  90045892 ns/op	11881112 B/op	  235928 allocs/op
BenchmarkClient_AddTemplate/Simple/20_Templates-12        	       6	 182456681 ns/op	23753468 B/op	  471812 allocs/op
BenchmarkClient_AddTemplate/Simple/50_Templates-12        	       3	 457135641 ns/op	59113586 B/op	 1179453 allocs/op
BenchmarkClient_AddTemplate/Simple/100_Templates-12       	       2	 915068659 ns/op	118516644 B/op	 2359408 allocs/op
BenchmarkClient_AddTemplate/Simple/200_Templates-12       	       1	1703187888 ns/op	236725560 B/op	 4719088 allocs/op
BenchmarkClient_AddTemplate/Complex/1_Templates-12        	      97	  10802338 ns/op	 1390259 B/op	   28547 allocs/op
BenchmarkClient_AddTemplate/Complex/2_Templates-12        	      46	  22915279 ns/op	 2877124 B/op	   60237 allocs/op
BenchmarkClient_AddTemplate/Complex/5_Templates-12        	      16	  63753467 ns/op	 8055650 B/op	  174220 allocs/op
BenchmarkClient_AddTemplate/Complex/10_Templates-12       	       8	 149904414 ns/op	18973611 B/op	  427264 allocs/op
BenchmarkClient_AddTemplate/Complex/20_Templates-12       	       3	 385724089 ns/op	49822754 B/op	 1170057 allocs/op
BenchmarkClient_AddTemplate/Complex/50_Templates-12       	       1	1471954431 ns/op	211890088 B/op	 5291328 allocs/op
BenchmarkClient_AddTemplate/Complex/100_Templates-12      	       1	4261518166 ns/op	715699320 B/op	18469732 allocs/op
BenchmarkClient_AddTemplate/Complex/200_Templates-12      	       1	13000580510 ns/op	2596388776 B/op	68489749 allocs/op

Fixes #151

Signed-off-by: Will Beason willbeason@google.com

Fixes open-policy-agent#151

Signed-off-by: Will Beason <willbeason@google.com>
@willbeason willbeason self-assigned this Nov 15, 2021
Signed-off-by: Will Beason <willbeason@google.com>
@codecov-commenter
Copy link

codecov-commenter commented Nov 15, 2021

Codecov Report

Merging #159 (596bf83) into master (8b4a99a) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #159   +/-   ##
=======================================
  Coverage   43.97%   43.97%           
=======================================
  Files          56       56           
  Lines        3131     3131           
=======================================
  Hits         1377     1377           
  Misses       1379     1379           
  Partials      375      375           
Flag Coverage Δ
unittests 43.97% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8b4a99a...596bf83. Read the comment docs.

Copy link
Contributor

@maxsmythe maxsmythe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@sozercan sozercan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@willbeason willbeason merged commit 217139c into open-policy-agent:master Nov 23, 2021
@willbeason willbeason deleted the bench-addtemplate branch November 23, 2021 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add client.AddTemplate benchmarks
4 participants