Compare commits

7 Commits

Author SHA1 Message Date
2673092b32 refactor: make graph target cross-platform
Replaced macOS-specific open command with file:// URL echo for cross-platform compatibility.
2026-01-11 16:10:47 -05:00
a13c5602dc feat: add clean target to remove build artifacts
Added clean target that removes the binary, program.out, and profile directory.
2026-01-11 16:07:39 -05:00
0fe4636c37 refactor: use .SILENT directive instead of @ prefixes
Replaced all @ prefixes with the .SILENT directive for cleaner Makefile syntax.
2026-01-11 16:06:34 -05:00
24a74e625d refactor: update binary name from lambda.exe to lambda
Changed BINARY_NAME from lambda.exe to lambda and updated all execution references to use the ${BINARY_NAME} variable.
Added lambda binary to .gitignore.
2026-01-11 16:05:50 -05:00
0260a065cb refactor: move TEST variable to top of Makefile
Moved TEST variable declaration to the top with other configuration variables for better organization.
2026-01-11 16:04:11 -05:00
e31fb88077 feat: add help target as default Makefile goal
Added a help target that displays all available Makefile targets with descriptions.
Set help as the default goal so running 'make' without arguments shows usage information.
2026-01-11 16:03:28 -05:00
099be4ede6 refactor: rename Makefile target from it to build
Renamed the 'it' target to 'build' for better clarity and conventional naming.
Updated all target dependencies (run, profile, explain) to reference the new build target.
2026-01-11 16:02:27 -05:00
2 changed files with 36 additions and 19 deletions

1
.gitignore vendored
View File

@@ -3,6 +3,7 @@
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
lambda
*.exe
*.exe~
*.dll

View File

@@ -1,27 +1,43 @@
BINARY_NAME=lambda.exe
.PHONY: it run profile explain graph docs
it:
@ go build -o ${BINARY_NAME} ./cmd/lambda
@ chmod +x ${BINARY_NAME}
BINARY_NAME=lambda
TEST=simple
run: it
@ ./lambda.exe - < ./samples/$(TEST).txt > program.out
.PHONY: help build run profile explain graph docs clean
.DEFAULT_GOAL := help
.SILENT:
profile: it
@ ./lambda.exe -p profile/cpu.prof - < ./samples/$(TEST).txt > program.out
help:
echo "Available targets:"
echo " build - Build the lambda executable"
echo " run - Build and run the lambda interpreter (use TEST=<name> to specify sample)"
echo " profile - Build and run with CPU profiling enabled"
echo " explain - Build and run with explanation mode and profiling"
echo " graph - Generate and open CPU profile visualization"
echo " docs - Start local godoc server on port 6060"
echo " clean - Remove all build artifacts"
explain: it
@ ./lambda.exe -x -p profile/cpu.prof - < ./samples/$(TEST).txt > program.out
build:
go build -o ${BINARY_NAME} ./cmd/lambda
chmod +x ${BINARY_NAME}
run: build
./${BINARY_NAME} - < ./samples/$(TEST).txt > program.out
profile: build
./${BINARY_NAME} -p profile/cpu.prof - < ./samples/$(TEST).txt > program.out
explain: build
./${BINARY_NAME} -x -p profile/cpu.prof - < ./samples/$(TEST).txt > program.out
graph:
@ go tool pprof -raw -output=profile/cpu.raw profile/cpu.prof
@ go tool pprof -svg profile/cpu.prof > profile/cpu.svg
@ open profile/cpu.svg
go tool pprof -raw -output=profile/cpu.raw profile/cpu.prof
go tool pprof -svg profile/cpu.prof > profile/cpu.svg
echo ">>> View at 'file://$(PWD)/profile/cpu.svg'"
docs:
@ echo ">>> View at 'http://localhost:6060/pkg/git.maximhutz.com/max/lambda/'"
@ go run golang.org/x/tools/cmd/godoc@latest -http=:6060
echo ">>> View at 'http://localhost:6060/pkg/git.maximhutz.com/max/lambda/'"
go run golang.org/x/tools/cmd/godoc@latest -http=:6060
clean:
rm -f ${BINARY_NAME}
rm -f program.out
rm -rf profile/