Skip to content

Commit

Permalink
revert ctx cmd/main.go
Browse files Browse the repository at this point in the history
Signed-off-by: Rajiv Singh <[email protected]>
  • Loading branch information
iamrajiv committed Aug 27, 2024
1 parent 7a2d7da commit 7fdee29
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions cmd/wzprof/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,6 @@ func (prog *program) run(ctx context.Context) error {

p := wzprof.ProfilingFor(wasmCode)

runtime := wazero.NewRuntimeWithConfig(ctx, wazero.NewRuntimeConfig().
WithDebugInfoEnabled(true).
WithCustomSections(true))

stdout.Printf("compiling wasm module %s", prog.filePath)
compiledModule, err := runtime.CompileModule(ctx, wasmCode)
if err != nil {
return fmt.Errorf("compiling wasm module: %w", err)
}
err = p.Prepare(compiledModule)
if err != nil {
return fmt.Errorf("preparing wasm module: %w", err)
}

cpu := p.CPUProfiler(wzprof.HostTime(prog.hostTime))
mem := p.MemoryProfiler(wzprof.InuseMemory(prog.inuseMemory))

Expand All @@ -92,6 +78,25 @@ func (prog *program) run(ctx context.Context) error {
}
}

ctx = context.WithValue(ctx,
experimental.FunctionListenerFactoryKey{},
experimental.MultiFunctionListenerFactory(listeners...),
)

runtime := wazero.NewRuntimeWithConfig(ctx, wazero.NewRuntimeConfig().
WithDebugInfoEnabled(true).
WithCustomSections(true))

stdout.Printf("compiling wasm module %s", prog.filePath)
compiledModule, err := runtime.CompileModule(ctx, wasmCode)
if err != nil {
return fmt.Errorf("compiling wasm module: %w", err)
}
err = p.Prepare(compiledModule)
if err != nil {
return fmt.Errorf("preparing wasm module: %w", err)
}

if prog.pprofAddr != "" {
u := &url.URL{Scheme: "http", Host: prog.pprofAddr, Path: "/debug/pprof"}
stdout.Printf("starting prrof http sever at %s", u)
Expand Down

0 comments on commit 7fdee29

Please sign in to comment.