-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
drop 0.4mb "runtime/pprof" and "runtime/trace" (#836)
- Loading branch information
Showing
4 changed files
with
91 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// +build !js !wasm | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"runtime/pprof" | ||
"runtime/trace" | ||
|
||
"github.com/evanw/esbuild/internal/logger" | ||
) | ||
|
||
func createTraceFile(osArgs []string, traceFile string) func() { | ||
f, err := os.Create(traceFile) | ||
if err != nil { | ||
logger.PrintErrorToStderr(osArgs, fmt.Sprintf( | ||
"Failed to create trace file: %s", err.Error())) | ||
return nil | ||
} | ||
trace.Start(f) | ||
return func() { | ||
trace.Stop() | ||
f.Close() | ||
} | ||
} | ||
|
||
func createHeapFile(osArgs []string, heapFile string) func() { | ||
f, err := os.Create(heapFile) | ||
if err != nil { | ||
logger.PrintErrorToStderr(osArgs, fmt.Sprintf( | ||
"Failed to create heap file: %s", err.Error())) | ||
return nil | ||
} | ||
return func() { | ||
if err := pprof.WriteHeapProfile(f); err != nil { | ||
logger.PrintErrorToStderr(osArgs, fmt.Sprintf( | ||
"Failed to write heap profile: %s", err.Error())) | ||
} | ||
f.Close() | ||
} | ||
} | ||
|
||
func createCpuprofileFile(osArgs []string, cpuprofileFile string) func() { | ||
f, err := os.Create(cpuprofileFile) | ||
if err != nil { | ||
logger.PrintErrorToStderr(osArgs, fmt.Sprintf( | ||
"Failed to create cpuprofile file: %s", err.Error())) | ||
return nil | ||
} | ||
pprof.StartCPUProfile(f) | ||
return func() { | ||
pprof.StopCPUProfile() | ||
f.Close() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// +build js,wasm | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/evanw/esbuild/internal/logger" | ||
) | ||
|
||
// Remove this code from the WebAssembly binary to reduce size. This only removes 0.4mb of stuff. | ||
|
||
func createTraceFile(osArgs []string, traceFile string) func() { | ||
logger.PrintErrorToStderr(osArgs, "The \"--trace\" flag is not supported when using WebAssembly") | ||
return nil | ||
} | ||
|
||
func createHeapFile(osArgs []string, heapFile string) func() { | ||
logger.PrintErrorToStderr(osArgs, "The \"--heap\" flag is not supported when using WebAssembly") | ||
return nil | ||
} | ||
|
||
func createCpuprofileFile(osArgs []string, cpuprofileFile string) func() { | ||
logger.PrintErrorToStderr(osArgs, "The \"--cpuprofile\" flag is not supported when using WebAssembly") | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters