Better profiling
This commit is contained in:
parent
209191af72
commit
b2b009037e
11
apple2.go
11
apple2.go
|
@ -9,7 +9,6 @@ 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
|
||||||
|
@ -26,7 +25,6 @@ type Apple2 struct {
|
||||||
isColor bool
|
isColor bool
|
||||||
fastMode bool
|
fastMode bool
|
||||||
fastRequestsCounter int
|
fastRequestsCounter int
|
||||||
profile bool
|
|
||||||
showSpeed bool
|
showSpeed bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,11 +38,6 @@ 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()
|
||||||
|
@ -98,10 +91,6 @@ 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
|
||||||
|
|
|
@ -97,10 +97,6 @@ func MainApple() *Apple2 {
|
||||||
"model",
|
"model",
|
||||||
"2enh",
|
"2enh",
|
||||||
"set base model. Models available 2plus, 2e, 2enh, base64a")
|
"set base model. Models available 2plus, 2e, 2enh, base64a")
|
||||||
profile := flag.Bool(
|
|
||||||
"profile",
|
|
||||||
false,
|
|
||||||
"generate profile trace to analyse with pprof")
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if *wozImage != "" {
|
if *wozImage != "" {
|
||||||
|
@ -174,7 +170,6 @@ 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)
|
|
||||||
|
|
||||||
// Load ROM if not loaded already
|
// Load ROM if not loaded already
|
||||||
if *romFile != "" {
|
if *romFile != "" {
|
||||||
|
|
|
@ -1,13 +1,26 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/ivanizag/apple2"
|
"github.com/ivanizag/apple2"
|
||||||
|
"github.com/pkg/profile"
|
||||||
"github.com/veandco/go-sdl2/sdl"
|
"github.com/veandco/go-sdl2/sdl"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
prof := flag.Bool(
|
||||||
|
"profile",
|
||||||
|
false,
|
||||||
|
"generate profile trace to analyse with pprof")
|
||||||
|
flag.Parse()
|
||||||
|
if *prof {
|
||||||
|
// See the log with:
|
||||||
|
// go tool pprof --pdf ~/go/bin/apple2sdl /tmp/profile329536248/cpu.pprof > profile.pdf
|
||||||
|
defer profile.Start().Stop()
|
||||||
|
}
|
||||||
|
|
||||||
a := apple2.MainApple()
|
a := apple2.MainApple()
|
||||||
if a != nil {
|
if a != nil {
|
||||||
SDLRun(a)
|
SDLRun(a)
|
||||||
|
|
Loading…
Reference in New Issue