mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-12 22:19:14 +00:00
Remove wzprof.
This commit is contained in:
6
go.mod
6
go.mod
@@ -5,15 +5,9 @@ go 1.19
|
||||
require (
|
||||
github.com/ncruces/julianday v0.1.5
|
||||
github.com/psanford/httpreadat v0.1.0
|
||||
github.com/stealthrocket/wzprof v0.1.5
|
||||
github.com/tetratelabs/wazero v1.1.1-0.20230522055633-256b7a4bf970
|
||||
golang.org/x/sync v0.2.0
|
||||
golang.org/x/sys v0.8.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/google/pprof v0.0.0-20230510103437-eeec1cb781c3 // indirect
|
||||
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
|
||||
)
|
||||
|
||||
retract v0.4.0 // tagged from the wrong branch
|
||||
|
||||
6
go.sum
6
go.sum
@@ -1,15 +1,9 @@
|
||||
github.com/google/pprof v0.0.0-20230510103437-eeec1cb781c3 h1:2XF1Vzq06X+inNqgJ9tRnGuw+ZVCB3FazXODD6JE1R8=
|
||||
github.com/google/pprof v0.0.0-20230510103437-eeec1cb781c3/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk=
|
||||
github.com/ncruces/julianday v0.1.5 h1:hDJ9ejiMp3DHsoZ5KW4c1lwfMjbARS7u/gbYcd0FBZk=
|
||||
github.com/ncruces/julianday v0.1.5/go.mod h1:Dusn2KvZrrovOMJuOt0TNXL6tB7U2E8kvza5fFc9G7g=
|
||||
github.com/psanford/httpreadat v0.1.0 h1:VleW1HS2zO7/4c7c7zNl33fO6oYACSagjJIyMIwZLUE=
|
||||
github.com/psanford/httpreadat v0.1.0/go.mod h1:Zg7P+TlBm3bYbyHTKv/EdtSJZn3qwbPwpfZ/I9GKCRE=
|
||||
github.com/stealthrocket/wzprof v0.1.5 h1:Y3jQHvdGFQMySV2VIjJhBu08OdcqcflfTz7CvrH5MGM=
|
||||
github.com/stealthrocket/wzprof v0.1.5/go.mod h1:hqLzj5iDSncc6rlPMhC51O642AkaC+dWVPNNalZdlCY=
|
||||
github.com/tetratelabs/wazero v1.1.1-0.20230522055633-256b7a4bf970 h1:X5OOeHRjoLA8XhVc7biEbh1/hnTzpYpPn7HuyarMslQ=
|
||||
github.com/tetratelabs/wazero v1.1.1-0.20230522055633-256b7a4bf970/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ=
|
||||
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc=
|
||||
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
|
||||
golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=
|
||||
golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
|
||||
|
||||
@@ -35,7 +35,7 @@ var (
|
||||
instances atomic.Uint64
|
||||
)
|
||||
|
||||
func init() {
|
||||
func TestMain(m *testing.M) {
|
||||
ctx := context.TODO()
|
||||
|
||||
rt = wazero.NewRuntime(ctx)
|
||||
@@ -52,6 +52,8 @@ func init() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
func config(ctx context.Context) wazero.ModuleConfig {
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"crypto/rand"
|
||||
"flag"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
@@ -16,9 +15,7 @@ import (
|
||||
|
||||
_ "embed"
|
||||
|
||||
"github.com/stealthrocket/wzprof"
|
||||
"github.com/tetratelabs/wazero"
|
||||
"github.com/tetratelabs/wazero/experimental"
|
||||
"github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1"
|
||||
|
||||
"github.com/ncruces/go-sqlite3/vfs"
|
||||
@@ -33,16 +30,12 @@ var (
|
||||
module wazero.CompiledModule
|
||||
output bytes.Buffer
|
||||
options []string
|
||||
cpuprof string
|
||||
memprof string
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
initFlags()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx, prof, cpu, mem := setupProfiling(ctx)
|
||||
|
||||
rt = wazero.NewRuntime(ctx)
|
||||
wasi_snapshot_preview1.MustInstantiate(ctx, rt)
|
||||
env := vfs.ExportHostFunctions(rt.NewHostModuleBuilder("env"))
|
||||
@@ -59,12 +52,10 @@ func TestMain(m *testing.M) {
|
||||
code := m.Run()
|
||||
defer os.Exit(code)
|
||||
io.Copy(os.Stderr, &output)
|
||||
saveProfiles(module, prof, cpu, mem)
|
||||
}
|
||||
|
||||
func initFlags() {
|
||||
i := 1
|
||||
wzprof := false
|
||||
options = append(options, "speedtest1")
|
||||
for _, arg := range os.Args[1:] {
|
||||
switch {
|
||||
@@ -72,9 +63,6 @@ func initFlags() {
|
||||
// keep test flags
|
||||
os.Args[i] = arg
|
||||
i++
|
||||
case strings.HasSuffix(arg, "-wzprof"):
|
||||
// collect guest profile
|
||||
wzprof = true
|
||||
default:
|
||||
// collect everything else
|
||||
options = append(options, arg)
|
||||
@@ -82,71 +70,6 @@ func initFlags() {
|
||||
}
|
||||
os.Args = os.Args[:i]
|
||||
flag.Parse()
|
||||
|
||||
if wzprof {
|
||||
var f *flag.Flag
|
||||
f = flag.Lookup("test.cpuprofile")
|
||||
cpuprof = f.Value.String()
|
||||
f.Value.Set("")
|
||||
f = flag.Lookup("test.memprofile")
|
||||
memprof = f.Value.String()
|
||||
f.Value.Set("")
|
||||
}
|
||||
}
|
||||
|
||||
func setupProfiling(ctx context.Context) (context.Context, *wzprof.Profiling, *wzprof.CPUProfiler, *wzprof.MemoryProfiler) {
|
||||
if cpuprof == "" && memprof == "" {
|
||||
return ctx, nil, nil, nil
|
||||
}
|
||||
|
||||
var cpu *wzprof.CPUProfiler
|
||||
var mem *wzprof.MemoryProfiler
|
||||
prof := wzprof.ProfilingFor(binary)
|
||||
|
||||
var listeners []experimental.FunctionListenerFactory
|
||||
if cpuprof != "" {
|
||||
cpu = prof.CPUProfiler()
|
||||
listeners = append(listeners, cpu)
|
||||
cpu.StartProfile()
|
||||
}
|
||||
if memprof != "" {
|
||||
mem = prof.MemoryProfiler()
|
||||
listeners = append(listeners, mem)
|
||||
}
|
||||
if listeners != nil {
|
||||
ctx = context.WithValue(ctx,
|
||||
experimental.FunctionListenerFactoryKey{},
|
||||
experimental.MultiFunctionListenerFactory(listeners...))
|
||||
}
|
||||
return ctx, prof, cpu, mem
|
||||
}
|
||||
|
||||
func saveProfiles(module wazero.CompiledModule, prof *wzprof.Profiling, cpu *wzprof.CPUProfiler, mem *wzprof.MemoryProfiler) {
|
||||
if cpu == nil && mem == nil {
|
||||
return
|
||||
}
|
||||
|
||||
log.SetOutput(io.Discard)
|
||||
err := prof.Prepare(module)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if cpu != nil {
|
||||
prof := cpu.StopProfile(1)
|
||||
err := wzprof.WriteProfile(cpuprof, prof)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
if mem != nil {
|
||||
prof := mem.NewProfile(1)
|
||||
err := wzprof.WriteProfile(memprof, prof)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_speedtest1(b *testing.B) {
|
||||
|
||||
Reference in New Issue
Block a user