This repository was archived by the owner on Jan 30, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change 1
1
package browser
2
2
3
3
import (
4
+ "log"
5
+ "net/http"
6
+ _ "net/http/pprof" // nolint:gosec
7
+ "os"
8
+
4
9
"github.com/grafana/xk6-browser/api"
5
10
"github.com/grafana/xk6-browser/chromium"
6
11
"github.com/grafana/xk6-browser/common"
37
42
_ k6modules.Instance = & ModuleInstance {}
38
43
)
39
44
45
+ func init () {
46
+ if _ , ok := os .LookupEnv ("XK6_BROWSER_PPROF" ); ok {
47
+ go func () {
48
+ address := "localhost:6060"
49
+ log .Println ("Starting http debug server" , address )
50
+ log .Println (http .ListenAndServe (address , nil ))
51
+ }()
52
+ }
53
+ }
54
+
40
55
// New returns a pointer to a new RootModule instance.
41
56
func New () * RootModule {
42
57
return & RootModule {}
@@ -69,16 +84,6 @@ func (mi *ModuleInstance) Exports() k6modules.Exports {
69
84
70
85
// Launch Chromium with given options.
71
86
func (m * JSModule ) Launch (opts goja.Value ) api.Browser {
72
- /*go func() {
73
- f, err := os.Create("./cpu.profile")
74
- if err != nil {
75
- log.Fatal(err)
76
- }
77
- pprof.StartCPUProfile(f)
78
- defer pprof.StopCPUProfile()
79
- <-ctx.Done()
80
- }()*/
81
-
82
87
ctx := k6ext .WithVU (m .vu .Context (), m .vu )
83
88
ctx = k6ext .WithCustomMetrics (ctx , m .k6Metrics )
84
89
You can’t perform that action at this time.
0 commit comments