-
Notifications
You must be signed in to change notification settings - Fork 0
/
bench_test.go
43 lines (36 loc) · 1.05 KB
/
bench_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package pointer_test
import (
"fmt"
"testing"
"github.com/BarrensZeppelin/pointer"
"github.com/BarrensZeppelin/pointer/pkgutil"
"github.com/stretchr/testify/require"
"golang.org/x/tools/go/packages"
"golang.org/x/tools/go/ssa"
"golang.org/x/tools/go/ssa/ssautil"
)
var blackHole any
// Benchmark performance of pointer analysis (and callgraph construction) on
// the standard library (w. tests)
func BenchmarkStdlibAnalysis(b *testing.B) {
pkgs, err := pkgutil.LoadPackagesWithConfig(
&packages.Config{
Mode: pkgutil.LoadMode,
Tests: true,
Dir: "",
}, "std")
require.NoError(b, err)
prog, spkgs := ssautil.AllPackages(pkgs, ssa.InstantiateGenerics)
prog.Build()
mains := ssautil.MainPackages(spkgs)
for _, methodsAreRoots := range [...]bool{false, true} {
b.Run(fmt.Sprintf("Steensgaard(MethodsAreRoots=%v)", methodsAreRoots),
func(b *testing.B) {
blackHole = pointer.Analyze(pointer.AnalysisConfig{
Program: prog,
EntryPackages: mains,
TreatMethodsAsRoots: methodsAreRoots,
})
})
}
}