Fixes lint issues, adds profile script
This commit is contained in:
parent
101119d3e5
commit
236df730ed
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
cpu.out
|
||||
linkheader.test
|
2
main.go
2
main.go
|
@ -63,7 +63,7 @@ func (l Links) FilterByRel(r string) Links {
|
|||
// String returns the string representation of multiple Links
|
||||
// for use in HTTP responses etc
|
||||
func (l Links) String() string {
|
||||
strs := make([]string, 0)
|
||||
var strs []string
|
||||
for _, link := range l {
|
||||
strs = append(strs, link.String())
|
||||
}
|
||||
|
|
11
main_test.go
11
main_test.go
|
@ -145,3 +145,14 @@ func TestLinksToString(t *testing.T) {
|
|||
t.Errorf("Want `%s`, have `%s`", want, have)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkParse(b *testing.B) {
|
||||
|
||||
header := "<https://api.github.com/user/9287/repos?page=3&per_page=100>; rel=\"next\", " +
|
||||
"<https://api.github.com/user/9287/repos?page=1&per_page=100>; rel=\"prev\"; pet=\"cat\", " +
|
||||
"<https://api.github.com/user/9287/repos?page=5&per_page=100>; rel=\"last\""
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = Parse(header)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#!/bin/sh
|
||||
PROJDIR=$(cd `dirname $0`/.. && pwd)
|
||||
|
||||
cd ${PROJDIR} && gometalinter
|
||||
cd ${PROJDIR}
|
||||
go get
|
||||
gometalinter
|
||||
|
|
7
script/profile
Executable file
7
script/profile
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
PROJDIR=$(cd `dirname $0`/.. && pwd)
|
||||
cd ${PROJDIR}
|
||||
|
||||
go test -bench . -benchmem -cpuprofile cpu.out
|
||||
go tool pprof linkheader.test cpu.out
|
Loading…
Reference in New Issue
Block a user