Exemple #1
0
func BenchmarkRendering(b *testing.B) {
	if sdl.Init(sdl.INIT_EVERYTHING) != 0 {
		log.Fatal(sdl.GetError())
	}

	screen := smslib.NewSDL2xScreen(false)

	displayLoop := smslib.NewSDLLoop(screen)
	go displayLoop.Run()

	sms := smslib.NewSMS(displayLoop)

	sms.LoadROM("../roms/blockhead.sms")

	numOfGeneratedFrames := 100
	generatedFrames := make([]smslib.DisplayData, numOfGeneratedFrames)

	for i := 0; i < numOfGeneratedFrames; i++ {
		generatedFrames = append(generatedFrames, *sms.RenderFrame())
	}

	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		for _, frame := range generatedFrames {
			displayLoop.Display() <- &frame
		}
	}
}
Exemple #2
0
// newEmulatorLoop returns a new emulatorLoop instance.
func newEmulatorLoop(displayLoop sms.DisplayLoop) *emulatorLoop {
	emulatorLoop := &emulatorLoop{
		ticker:         time.NewTicker(time.Duration(1e9 / 50)), // 50 Hz
		sms:            sms.NewSMS(displayLoop),
		pause:          make(chan int),
		terminate:      make(chan int),
		pauseEmulation: make(chan int),
	}
	if flag.Arg(0) == "" {
		return nil
	}
	emulatorLoop.sms.LoadROM(flag.Arg(0))
	return emulatorLoop
}
Exemple #3
0
func BenchmarkCPU(b *testing.B) {
	if sdl.Init(sdl.INIT_EVERYTHING) != 0 {
		log.Fatal(sdl.GetError())
	}

	screen := smslib.NewSDL2xScreen(false)

	displayLoop := smslib.NewSDLLoop(screen)
	go displayLoop.Run()

	sms := smslib.NewSMS(displayLoop)

	sms.LoadROM("../roms/blockhead.sms")

	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		sms.RenderFrame()
	}
}