-
Notifications
You must be signed in to change notification settings - Fork 148
Testing & Benchmarking
Henry Case edited this page Sep 12, 2019
·
3 revisions
Library comes with number of make targets which are used for testing, benchmarking and during CI runs:
* test
: performs testing of the binary.
* bench
: runs benchmarks.
* cover
: produces coverage.
* lint
: runs set of linters on the code base
Additionally user can set following environment variables:
* GO
: path to the GO executable (default "go")
* NOASM
: indicates whether assembly implementation must or can't be used (default 0 - ASM used)
* OPTS
: free text, options to be passed to "go test" tool (default "-v")
Makefile ensures environment for testing is set correctly and tests are executed in same fashion every time.
In order to run tests, clone the repo:
git clone git@github.com:cloudflare/circl.git
Example of running tests and benchmarks:
> make test
rm -rf /home/hdc/repos/cloudflare/circl/build
go vet ./...
go test -v ./...
? github.com/cloudflare/circl [no test files]
? github.com/cloudflare/circl/dh [no test files]
=== RUN TestDH
--- PASS: TestDH (0.29s)
=== RUN ExampleKey
--- PASS: ExampleKey (0.00s)
PASS
....
# run benchmarks
> make bench
rm -rf /home/hdc/repos/cloudflare/circl/build
goos: linux
goarch: amd64
pkg: github.com/cloudflare/circl/dh/sidh
BenchmarkSidhKeyAgreementP503-4 200 6053900 ns/op 51 B/op 0 allocs/op
BenchmarkAliceKeyGenPrvP503-4 2000000 693 ns/op 0 B/op 0 allocs/op
...
# benchmark implementation that doesn't use assembly
> NOASM=1 make bench
rm -rf /home/hdc/repos/cloudflare/circl/build
go test -bench=. -run="^_" -benchmem --tags noasm -v ./...
goos: linux
goarch: amd64
pkg: github.com/cloudflare/circl/dh/sidh
BenchmarkSidhKeyAgreementP503-4 100 18957221 ns/op 103 B/op 0 allocs/op
BenchmarkAliceKeyGenPrvP503-4 2000000 708 ns/op 0 B/op 0 allocs/op
...