Run benchmarks and fmt in travis (#174)
This commit is contained in:
@@ -10,7 +10,9 @@ matrix:
|
|||||||
- go: tip
|
- go: tip
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
script:
|
script:
|
||||||
|
- if [ -n "$(go fmt ./...)" ]; then exit 1; fi
|
||||||
- ./test.sh
|
- ./test.sh
|
||||||
|
- ./benchmark.sh $TRAVIS_BRANCH https://github.com/$TRAVIS_REPO_SLUG.git
|
||||||
before_install:
|
before_install:
|
||||||
- go get github.com/axw/gocov/gocov
|
- go get github.com/axw/gocov/gocov
|
||||||
- go get github.com/mattn/goveralls
|
- go get github.com/mattn/goveralls
|
||||||
|
|||||||
Executable
+32
@@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
reference_ref=${1:-master}
|
||||||
|
reference_git=${2:-.}
|
||||||
|
|
||||||
|
if ! `hash benchstat 2>/dev/null`; then
|
||||||
|
echo "Installing benchstat"
|
||||||
|
go get golang.org/x/perf/cmd/benchstat
|
||||||
|
go install golang.org/x/perf/cmd/benchstat
|
||||||
|
fi
|
||||||
|
|
||||||
|
tempdir=`mktemp -d /tmp/go-toml-benchmark-XXXXXX`
|
||||||
|
ref_tempdir="${tempdir}/ref"
|
||||||
|
ref_benchmark="${ref_tempdir}/benchmark-${reference_ref}.txt"
|
||||||
|
local_benchmark="`pwd`/benchmark-local.txt"
|
||||||
|
|
||||||
|
echo "=== ${reference_ref} (${ref_tempdir})"
|
||||||
|
git clone ${reference_git} ${ref_tempdir} >/dev/null 2>/dev/null
|
||||||
|
pushd ${ref_tempdir} >/dev/null
|
||||||
|
git checkout ${reference_ref} >/dev/null 2>/dev/null
|
||||||
|
go test -bench=. -benchmem | tee ${ref_benchmark}
|
||||||
|
popd >/dev/null
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "=== local"
|
||||||
|
go test -bench=. -benchmem | tee ${local_benchmark}
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "=== diff"
|
||||||
|
benchstat -delta-test=none ${ref_benchmark} ${local_benchmark}
|
||||||
+4
-4
@@ -7,10 +7,10 @@ package query
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/pelletier/go-toml"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
"github.com/pelletier/go-toml"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Lexer state function
|
// Lexer state function
|
||||||
@@ -55,7 +55,7 @@ func (l *queryLexer) nextStart() {
|
|||||||
|
|
||||||
func (l *queryLexer) emit(t tokenType) {
|
func (l *queryLexer) emit(t tokenType) {
|
||||||
l.tokens <- token{
|
l.tokens <- token{
|
||||||
Position: toml.Position{Line:l.line, Col:l.col},
|
Position: toml.Position{Line: l.line, Col: l.col},
|
||||||
typ: t,
|
typ: t,
|
||||||
val: l.input[l.start:l.pos],
|
val: l.input[l.start:l.pos],
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ func (l *queryLexer) emit(t tokenType) {
|
|||||||
|
|
||||||
func (l *queryLexer) emitWithValue(t tokenType, value string) {
|
func (l *queryLexer) emitWithValue(t tokenType, value string) {
|
||||||
l.tokens <- token{
|
l.tokens <- token{
|
||||||
Position: toml.Position{Line:l.line, Col:l.col},
|
Position: toml.Position{Line: l.line, Col: l.col},
|
||||||
typ: t,
|
typ: t,
|
||||||
val: value,
|
val: value,
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ func (l *queryLexer) backup() {
|
|||||||
|
|
||||||
func (l *queryLexer) errorf(format string, args ...interface{}) queryLexStateFn {
|
func (l *queryLexer) errorf(format string, args ...interface{}) queryLexStateFn {
|
||||||
l.tokens <- token{
|
l.tokens <- token{
|
||||||
Position: toml.Position{Line:l.line, Col:l.col},
|
Position: toml.Position{Line: l.line, Col: l.col},
|
||||||
typ: tokenError,
|
typ: tokenError,
|
||||||
val: fmt.Sprintf(format, args...),
|
val: fmt.Sprintf(format, args...),
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,8 +1,8 @@
|
|||||||
package query
|
package query
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
|
||||||
"github.com/pelletier/go-toml"
|
"github.com/pelletier/go-toml"
|
||||||
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func testQLFlow(t *testing.T, input string, expectedFlow []token) {
|
func testQLFlow(t *testing.T, input string, expectedFlow []token) {
|
||||||
|
|||||||
+1
-1
@@ -2,8 +2,8 @@ package query
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
|
||||||
"github.com/pelletier/go-toml"
|
"github.com/pelletier/go-toml"
|
||||||
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
// dump path tree to a string
|
// dump path tree to a string
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ package query
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/pelletier/go-toml"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
"github.com/pelletier/go-toml"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type queryTestNode struct {
|
type queryTestNode struct {
|
||||||
|
|||||||
+3
-4
@@ -1,10 +1,10 @@
|
|||||||
package query
|
package query
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
|
||||||
"unicode"
|
|
||||||
"github.com/pelletier/go-toml"
|
"github.com/pelletier/go-toml"
|
||||||
|
"strconv"
|
||||||
|
"unicode"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Define tokens
|
// Define tokens
|
||||||
@@ -104,4 +104,3 @@ func isHexDigit(r rune) bool {
|
|||||||
(r >= 'a' && r <= 'f') ||
|
(r >= 'a' && r <= 'f') ||
|
||||||
(r >= 'A' && r <= 'F')
|
(r >= 'A' && r <= 'F')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user