diff --git a/benchmarker/Makefile b/benchmarker/Makefile index 5f85d9df..0ac39b7d 100644 --- a/benchmarker/Makefile +++ b/benchmarker/Makefile @@ -1,4 +1,4 @@ all: bin/benchmarker -bin/benchmarker: *.go checker/*.go +bin/benchmarker: *.go checker/*.go go.mod go.sum go build -o bin/benchmarker diff --git a/benchmarker/scenario.go b/benchmarker/scenario.go index 871ac787..7a65bee3 100644 --- a/benchmarker/scenario.go +++ b/benchmarker/scenario.go @@ -34,25 +34,25 @@ func loadImages(s *checker.Session, imageURLs []string) { } func extractImages(doc *goquery.Document) []string { - imageURLs := []string{} + imageURLs := make([]string, 0, PostsPerPage) - doc.Find("img.isu-image").Each(func(_ int, selection *goquery.Selection) { - if url, ok := selection.Attr("src"); ok { + for _, el := range doc.Find("img.isu-image").EachIter() { + if url, ok := el.Attr("src"); ok { imageURLs = append(imageURLs, url) } - }).Length() + } return imageURLs } func extractPostLinks(doc *goquery.Document) []string { - postLinks := []string{} + postLinks := make([]string, 0, PostsPerPage) - doc.Find("a.isu-post-permalink").Each(func(_ int, selection *goquery.Selection) { - if url, ok := selection.Attr("href"); ok { + for _, el := range doc.Find("a.isu-post-permalink").EachIter() { + if url, ok := el.Attr("href"); ok { postLinks = append(postLinks, url) } - }).Length() + } return postLinks }