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

test(validators): benchmark all the relevant validators #56

Merged
merged 1 commit into from
Nov 6, 2019

Conversation

asido
Copy link
Contributor

@asido asido commented Sep 3, 2019

Motivation

I started doing some drastic changes in PR #55. However, I want to have benchmarks available before I finish the implementation. This diff benchmarks all the relevant validators except validators such as anyOf, if, etc.

Each benchmark runs with 4 different sample sizes - 1, 10, 100, 1000. It allows one to see validator's time complexity - which are O(1) and which are O(n). PR #55 will change that slightly.

Output

$ go test -bench="Benchmark*" -run="^a" -benchmem
goos: darwin
goarch: amd64
pkg: github.com/qri-io/jsonschema
BenchmarkAdditionalItems/sample_size_1-8         	 5000000	       392 ns/op	      52 B/op	       5 allocs/op
BenchmarkAdditionalItems/sample_size_10-8        	 1000000	      2133 ns/op	     232 B/op	      32 allocs/op
BenchmarkAdditionalItems/sample_size_100-8       	  100000	     20196 ns/op	    2248 B/op	     302 allocs/op
BenchmarkAdditionalItems/sample_size_1000-8      	   10000	    231324 ns/op	   27448 B/op	    3902 allocs/op
BenchmarkAdditionalProperties/sample_size_1-8    	 3000000	       550 ns/op	      54 B/op	       5 allocs/op
BenchmarkAdditionalProperties/sample_size_10-8   	  300000	      3955 ns/op	     256 B/op	      32 allocs/op
BenchmarkAdditionalProperties/sample_size_100-8  	   10000	    101646 ns/op	    2430 B/op	     302 allocs/op
BenchmarkAdditionalProperties/sample_size_1000-8 	     200	   8414009 ns/op	   26619 B/op	    3002 allocs/op
BenchmarkConst/sample_size_1-8                   	 1000000	      1074 ns/op	     720 B/op	      13 allocs/op
BenchmarkConst/sample_size_10-8                  	  300000	      5904 ns/op	    2134 B/op	      68 allocs/op
BenchmarkConst/sample_size_100-8                 	   30000	     56050 ns/op	   20590 B/op	     616 allocs/op
BenchmarkConst/sample_size_1000-8                	    2000	    612953 ns/op	  267268 B/op	    6037 allocs/op
BenchmarkContains/sample_size_1-8                	 3000000	       479 ns/op	     208 B/op	       3 allocs/op
BenchmarkContains/sample_size_10-8               	  200000	      8840 ns/op	    3170 B/op	      85 allocs/op
BenchmarkContains/sample_size_100-8              	   20000	     97857 ns/op	   33511 B/op	    1094 allocs/op
BenchmarkContains/sample_size_1000-8             	    2000	    963205 ns/op	  336132 B/op	   10995 allocs/op
BenchmarkDependencies/sample_size_1-8            	 5000000	       376 ns/op	      38 B/op	       4 allocs/op
BenchmarkDependencies/sample_size_10-8           	 3000000	       535 ns/op	      38 B/op	       4 allocs/op
BenchmarkDependencies/sample_size_100-8          	 1000000	      1943 ns/op	      38 B/op	       4 allocs/op
BenchmarkDependencies/sample_size_1000-8         	   50000	     24686 ns/op	      38 B/op	       4 allocs/op
BenchmarkEnum/sample_size_1-8                    	 5000000	       367 ns/op	     176 B/op	       2 allocs/op
BenchmarkEnum/sample_size_10-8                   	  300000	      4488 ns/op	    1657 B/op	      42 allocs/op
BenchmarkEnum/sample_size_100-8                  	   30000	     41264 ns/op	   15306 B/op	     483 allocs/op
BenchmarkEnum/sample_size_1000-8                 	    3000	    416227 ns/op	  152206 B/op	    4983 allocs/op
BenchmarkMaximum/sample_size_1-8                 	30000000	        43.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkMaximum/sample_size_10-8                	30000000	        41.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkMaximum/sample_size_100-8               	30000000	        42.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkMaximum/sample_size_1000-8              	30000000	        42.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkMinimum/sample_size_1-8                 	30000000	        43.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkMinimum/sample_size_10-8                	30000000	        42.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkMinimum/sample_size_100-8               	30000000	        42.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkMinimum/sample_size_1000-8              	30000000	        43.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkExclusiveMaximum/sample_size_1-8        	30000000	        43.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkExclusiveMaximum/sample_size_10-8       	30000000	        44.1 ns/op	       0 B/op	       0 allocs/op
BenchmarkExclusiveMaximum/sample_size_100-8      	30000000	        43.1 ns/op	       0 B/op	       0 allocs/op
BenchmarkExclusiveMaximum/sample_size_1000-8     	30000000	        43.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkExclusiveMinimum/sample_size_1-8        	30000000	        42.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkExclusiveMinimum/sample_size_10-8       	30000000	        41.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkExclusiveMinimum/sample_size_100-8      	30000000	        43.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkExclusiveMinimum/sample_size_1000-8     	30000000	        44.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkMaxItems/sample_size_1-8                	30000000	        43.1 ns/op	       0 B/op	       0 allocs/op
BenchmarkMaxItems/sample_size_10-8               	30000000	        42.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkMaxItems/sample_size_100-8              	30000000	        42.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkMaxItems/sample_size_1000-8             	30000000	        42.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkMinItems/sample_size_1-8                	30000000	        42.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkMinItems/sample_size_10-8               	30000000	        42.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkMinItems/sample_size_100-8              	30000000	        42.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkMinItems/sample_size_1000-8             	30000000	        42.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkMaxLength/sample_size_1-8               	30000000	        45.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkMaxLength/sample_size_10-8              	30000000	        49.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkMaxLength/sample_size_100-8             	20000000	       109 ns/op	       0 B/op	       0 allocs/op
BenchmarkMaxLength/sample_size_1000-8            	 3000000	       574 ns/op	       0 B/op	       0 allocs/op
BenchmarkMinLength/sample_size_1-8               	30000000	        44.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkMinLength/sample_size_10-8              	30000000	        52.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkMinLength/sample_size_100-8             	20000000	       109 ns/op	       0 B/op	       0 allocs/op
BenchmarkMinLength/sample_size_1000-8            	 3000000	       593 ns/op	       0 B/op	       0 allocs/op
BenchmarkMaxProperties/sample_size_1-8           	30000000	        43.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkMaxProperties/sample_size_10-8          	30000000	        43.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkMaxProperties/sample_size_100-8         	30000000	        43.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkMaxProperties/sample_size_1000-8        	30000000	        44.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkMinProperties/sample_size_1-8           	30000000	        42.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkMinProperties/sample_size_10-8          	30000000	        42.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkMinProperties/sample_size_100-8         	30000000	        41.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkMinProperties/sample_size_1000-8        	30000000	        42.1 ns/op	       0 B/op	       0 allocs/op
BenchmarkMultipleOf/sample_size_1-8              	30000000	        43.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkMultipleOf/sample_size_10-8             	30000000	        43.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkMultipleOf/sample_size_100-8            	30000000	        44.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkMultipleOf/sample_size_1000-8           	30000000	        44.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkPattern/sample_size_1-8                 	 5000000	       234 ns/op	     152 B/op	       2 allocs/op
BenchmarkPattern/sample_size_10-8                	 3000000	       406 ns/op	     160 B/op	       2 allocs/op
BenchmarkPattern/sample_size_100-8               	 1000000	      1983 ns/op	     256 B/op	       2 allocs/op
BenchmarkPattern/sample_size_1000-8              	  100000	     17252 ns/op	    1168 B/op	       2 allocs/op
BenchmarkType/sample_size_1-8                    	 1000000	      2171 ns/op	     150 B/op	      19 allocs/op
BenchmarkType/sample_size_10-8                   	  100000	     22500 ns/op	    1360 B/op	     181 allocs/op
BenchmarkType/sample_size_100-8                  	    5000	    246583 ns/op	   14392 B/op	    1801 allocs/op
BenchmarkType/sample_size_1000-8                 	     500	   2648283 ns/op	  159488 B/op	   18001 allocs/op
PASS
ok  	github.com/qri-io/jsonschema	123.744s

@b5
Copy link
Member

b5 commented Nov 6, 2019

Hi @asido apologies for not being more encouraging of these PRs, this stuff is really great! I'm going to get this merged, and if you have any interest in continuing with #55, let me know.

Thanks again, and apologies for the long period of silence

@b5 b5 merged commit 1fbc1e0 into qri-io:master Nov 6, 2019
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.

2 participants