mirror of
https://github.com/ivanizag/izapple2.git
synced 2025-02-07 13:30:57 +00:00
Add the -profile option
This commit is contained in:
parent
6917a21f38
commit
b89f88d879
@ -133,6 +133,8 @@ Only valid on SDL mode
|
|||||||
emulate a green phosphor monitor instead of a NTSC color TV. Use F6 to toggle.
|
emulate a green phosphor monitor instead of a NTSC color TV. Use F6 to toggle.
|
||||||
-panicss
|
-panicss
|
||||||
panic if a not implemented softswitch is used
|
panic if a not implemented softswitch is used
|
||||||
|
-profile
|
||||||
|
generate profile trace to analyse with pprof
|
||||||
-rom string
|
-rom string
|
||||||
main rom file (default "<internal>/Apple2_Plus.rom")
|
main rom file (default "<internal>/Apple2_Plus.rom")
|
||||||
-saturnCardSlot int
|
-saturnCardSlot int
|
||||||
|
17
apple2.go
17
apple2.go
@ -9,6 +9,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ivanizag/apple2/core6502"
|
"github.com/ivanizag/apple2/core6502"
|
||||||
|
"github.com/pkg/profile"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Apple2 represents all the components and state of the emulated machine
|
// Apple2 represents all the components and state of the emulated machine
|
||||||
@ -25,6 +26,7 @@ type Apple2 struct {
|
|||||||
isColor bool
|
isColor bool
|
||||||
fastMode bool
|
fastMode bool
|
||||||
fastRequestsCounter int
|
fastRequestsCounter int
|
||||||
|
profile bool
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -37,6 +39,12 @@ const maxWaitDuration = 100 * time.Millisecond
|
|||||||
|
|
||||||
// Run starts the Apple2 emulation
|
// Run starts the Apple2 emulation
|
||||||
func (a *Apple2) Run() {
|
func (a *Apple2) Run() {
|
||||||
|
if a.profile {
|
||||||
|
// See the log with:
|
||||||
|
// go tool pprof --pdf ~/go/bin/apple2sdl /tmp/profile329536248/cpu.pprof > profile.pdf
|
||||||
|
defer profile.Start().Stop()
|
||||||
|
}
|
||||||
|
|
||||||
// Start the processor
|
// Start the processor
|
||||||
a.cpu.Reset()
|
a.cpu.Reset()
|
||||||
referenceTime := time.Now()
|
referenceTime := time.Now()
|
||||||
@ -50,6 +58,9 @@ func (a *Apple2) Run() {
|
|||||||
for commandsPending {
|
for commandsPending {
|
||||||
select {
|
select {
|
||||||
case command := <-a.commandChannel:
|
case command := <-a.commandChannel:
|
||||||
|
if command == CommandKill {
|
||||||
|
return
|
||||||
|
}
|
||||||
a.executeCommand(command)
|
a.executeCommand(command)
|
||||||
default:
|
default:
|
||||||
commandsPending = false
|
commandsPending = false
|
||||||
@ -73,6 +84,10 @@ func (a *Apple2) Run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *Apple2) setProfile(value bool) {
|
||||||
|
a.profile = value
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// CommandToggleSpeed toggles cpu speed between full speed and actual Apple II speed
|
// CommandToggleSpeed toggles cpu speed between full speed and actual Apple II speed
|
||||||
CommandToggleSpeed = iota + 1
|
CommandToggleSpeed = iota + 1
|
||||||
@ -88,6 +103,8 @@ const (
|
|||||||
CommandNextCharGenPage
|
CommandNextCharGenPage
|
||||||
// CommandToggleCPUTrace toggle tracing of CPU execution
|
// CommandToggleCPUTrace toggle tracing of CPU execution
|
||||||
CommandToggleCPUTrace
|
CommandToggleCPUTrace
|
||||||
|
// CommandKill stops the cpu execution loop
|
||||||
|
CommandKill
|
||||||
)
|
)
|
||||||
|
|
||||||
// SendCommand enqueues a command to the emulator thread
|
// SendCommand enqueues a command to the emulator thread
|
||||||
|
@ -86,6 +86,11 @@ func MainApple() *Apple2 {
|
|||||||
false,
|
false,
|
||||||
"setup a Base64A clone",
|
"setup a Base64A clone",
|
||||||
)
|
)
|
||||||
|
profile := flag.Bool(
|
||||||
|
"profile",
|
||||||
|
false,
|
||||||
|
"generate profile trace to analyse with pprof",
|
||||||
|
)
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
a := NewApple2(*cpuClock, !*mono, *fastDisk)
|
a := NewApple2(*cpuClock, !*mono, *fastDisk)
|
||||||
@ -93,6 +98,7 @@ func MainApple() *Apple2 {
|
|||||||
a.cpu.SetTrace(*traceCPU)
|
a.cpu.SetTrace(*traceCPU)
|
||||||
a.io.setTrace(*traceSS)
|
a.io.setTrace(*traceSS)
|
||||||
a.io.setPanicNotImplemented(*panicSS)
|
a.io.setPanicNotImplemented(*panicSS)
|
||||||
|
a.setProfile(*profile)
|
||||||
|
|
||||||
if *charRomFile != "" {
|
if *charRomFile != "" {
|
||||||
cg, err := NewCharacterGenerator(*charRomFile)
|
cg, err := NewCharacterGenerator(*charRomFile)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user