MCPcopy Create free account
hub / github.com/efficientgo/e2e / AsProfiled

Function AsProfiled

profiling/profiled.go:57–81  ·  view source on GitHub ↗

AsProfiled wraps e2e.Runnable with ProfiledRunnable. If runnable is running during invocation AsProfiled panics. NOTE(bwplotka): Caller is expected to discard passed `r` runnable and use returned ProfiledRunnable.Runnable instead.

(r e2e.Runnable, pprofPortName string, opts ...ProfiledOption)

Source from the content-addressed store, hash-verified

55// If runnable is running during invocation AsProfiled panics.
56// NOTE(bwplotka): Caller is expected to discard passed `r` runnable and use returned ProfiledRunnable.Runnable instead.
57func AsProfiled(r e2e.Runnable, pprofPortName string, opts ...ProfiledOption) *ProfiledRunnable {
58 if r.IsRunning() {
59 panic("can't use AsProfiled with running runnable")
60 }
61
62 opt := rOpt{
63 scheme: "http",
64 }
65 for _, o := range opts {
66 o(&opt)
67 }
68
69 if r.InternalEndpoint(pprofPortName) == "" {
70 return &ProfiledRunnable{Runnable: e2e.NewFailedRunnable(r.Name(), errors.Newf("pprof port name %v does not exist in given runnable ports", pprofPortName))}
71 }
72
73 instr := &ProfiledRunnable{
74 Runnable: r,
75 pprofPort: pprofPortName,
76 scheme: opt.scheme,
77 config: opt.config,
78 }
79 r.SetMetadata(metaKey, Profiled(instr))
80 return instr
81}
82
83func (r *ProfiledRunnable) ProfileTargets() []Target {
84 return []Target{{Name: r.Name(), Scheme: r.scheme, Config: r.config, InternalEndpoint: r.InternalEndpoint(r.pprofPort)}}

Callers

nothing calls this directly

Calls 6

NewFailedRunnableFunction · 0.92
ProfiledInterface · 0.85
IsRunningMethod · 0.65
InternalEndpointMethod · 0.65
NameMethod · 0.65
SetMetadataMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…