Skip to content

Commit

Permalink
add benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkvist committed Jul 23, 2019
1 parent 3f601c3 commit 629c44b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,29 @@ func TestParse(t *testing.T) {
})
}
}

func BenchmarkParse1Line(b *testing.B) {
benchmarkParse(b, "Google,https://google.com/")
}

func BenchmarkParse50Lines(b *testing.B) {
in := strings.Repeat("500px,https://500px.com\n", 50)
benchmarkParse(b, in)
}

func BenchmarkParse100Lines(b *testing.B) {
in := strings.Repeat("500px,https://500px.com/\n", 100)
benchmarkParse(b, in)
}

func BenchmarkParse500Lines(b *testing.B) {
in := strings.Repeat("500px,https://500px.com\n", 500)
benchmarkParse(b, in)
}

func benchmarkParse(b *testing.B, input string) {
r := csv.NewReader(strings.NewReader(input))
for n := 0; n < b.N; n++ {
parse(r)
}
}

0 comments on commit 629c44b

Please sign in to comment.