2017-08-07 09:53:20 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func benchmarkPrintSearch(search string, b *testing.B) {
|
|
|
|
old := os.Stdout
|
|
|
|
_, w, _ := os.Pipe()
|
|
|
|
os.Stdout = w
|
|
|
|
|
|
|
|
for n := 0; n < b.N; n++ {
|
2018-08-29 19:19:31 +00:00
|
|
|
res, _ := queryRepo(append([]string{}, search))
|
2017-08-07 09:53:20 +00:00
|
|
|
res.printSearch()
|
|
|
|
}
|
|
|
|
os.Stdout = old
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkPrintSearchSimpleTopDown(b *testing.B) {
|
|
|
|
config.SortMode = TopDown
|
|
|
|
benchmarkPrintSearch("chromium", b)
|
|
|
|
}
|
|
|
|
func BenchmarkPrintSearchComplexTopDown(b *testing.B) {
|
|
|
|
config.SortMode = TopDown
|
|
|
|
benchmarkPrintSearch("linux", b)
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkPrintSearchSimpleBottomUp(b *testing.B) {
|
|
|
|
config.SortMode = BottomUp
|
|
|
|
benchmarkPrintSearch("chromium", b)
|
|
|
|
}
|
|
|
|
func BenchmarkPrintSearchComplexBottomUp(b *testing.B) {
|
|
|
|
config.SortMode = BottomUp
|
|
|
|
benchmarkPrintSearch("linux", b)
|
|
|
|
}
|