profile

command
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2025 License: MIT Imports: 11 Imported by: 0

README

Monke Profiling Tool

This tool is used to profile the Monke interpreter with various sample programs to identify performance bottlenecks.

Usage

# Build the profiling tool
cd cmd/profile
go build

# Run with default settings (fibonacci program)
./profile

# Run with CPU profiling
./profile -cpuprofile=cpu.prof

# Run with memory profiling
./profile -memprofile=mem.prof

# Run with execution tracing
./profile -trace=trace.out

# Run a different program
./profile -program=factorial
./profile -program=array
./profile -program=hash
./profile -program=complex

Available Programs

  • fibonacci: Calculates the 20th Fibonacci number using recursion
  • factorial: Calculates the factorial of 10 using recursion
  • array: Demonstrates array operations with map and reduce functions
  • hash: Demonstrates hash table operations
  • complex: A complex program that combines multiple features

Analyzing Profiling Results

To analyze CPU profiling results:

go tool pprof -top cpu.prof

To analyze memory profiling results:

go tool pprof -top mem.prof

To view the execution trace:

go tool trace trace.out

Documentation

Overview

Command profile runs a Monkey program and measures its execution time.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL