From 5a1a40d53b2bcc6d5740ced982d8c13b47d287fc Mon Sep 17 00:00:00 2001 From: Karan Misra Date: Sun, 23 Mar 2014 05:23:25 +0530 Subject: [PATCH] - add a benchmark test for pinMap lookup - run benchmarks in ci --- .travis.yml | 2 +- pin_test.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e25f3c4..3e57700 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,5 +6,5 @@ go: - tip script: - - go test ./... | grep -v 'no test files' + - go test -bench=. -v ./... | grep -v 'no test files' - pushd samples && find . -name "*.go" -exec go build {} \; && popd diff --git a/pin_test.go b/pin_test.go index 8aea34b..10eef62 100644 --- a/pin_test.go +++ b/pin_test.go @@ -45,3 +45,13 @@ func TestPinMapLookup(t *testing.T) { } } } + +func BenchmarkPinMapLookup(b *testing.B) { + var pinMap = PinMap{ + &PinDesc{ID: "P1_1", Aliases: []string{"AN1", "10"}, Caps: CapAnalog}, + &PinDesc{ID: "P1_2", Aliases: []string{"10", "GPIO10"}, Caps: CapNormal}, + } + for i := 0; i < b.N; i++ { + pinMap.Lookup("GPIO10", CapNormal) + } +}