VM to optimize currentFrame and add profiling
Some checks failed
Build / build (push) Failing after 5m50s
Publish Image / publish (push) Failing after 35s
Test / build (push) Failing after 5m30s

This commit is contained in:
Chuck Smith
2024-03-28 15:53:00 -04:00
parent 834de04635
commit 362138ff2e
2 changed files with 61 additions and 52 deletions

13
main.go
View File

@@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"github.com/pkg/profile"
"io"
"log"
"monkey/compiler"
@@ -22,6 +23,9 @@ var (
compile bool
version bool
debug bool
profileCPU bool
profileMem bool
)
func init() {
@@ -37,6 +41,9 @@ func init() {
flag.BoolVar(&interactive, "i", false, "enable interactive mode")
flag.StringVar(&engine, "e", "vm", "engine to use (eval or vm)")
flag.BoolVar(&profileCPU, "profile-cpu", false, "Enable CPU profiling.")
flag.BoolVar(&profileMem, "profile-mem", false, "Enable Memory profiling.")
}
// Indent indents a block of text with an indent string
@@ -70,6 +77,12 @@ func main() {
args := flag.Args()
if profileCPU {
defer profile.Start(profile.CPUProfile).Stop()
} else if profileMem {
defer profile.Start(profile.MemProfile).Stop()
}
if compile {
if len(args) < 1 {
log.Fatal("no source file given to compile")