nga-python: add stubs for benchmark device (#28); add support for running under Python2 (for use w/pypy)
FossilOrigin-Name: 2b8e1c48bdb444f0b08f9813fa09493455f801e058146e75a27acb35a2907393
This commit is contained in:
parent
6ea19bbdd2
commit
b1dce01d9d
2 changed files with 40 additions and 1 deletions
23
vm/nga-python/BenchmarkDevice.py
Normal file
23
vm/nga-python/BenchmarkDevice.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Benchmark Support
|
||||
#
|
||||
# This is intended to help support benchmarking by
|
||||
# providing high resolution timing and instruction
|
||||
# usage data.
|
||||
#
|
||||
|
||||
import time
|
||||
|
||||
|
||||
class BenchmarkDevice:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def execute(self, retro_instance, pointer):
|
||||
return 0
|
||||
|
||||
def timer_resolution(self):
|
||||
try:
|
||||
time.time_ns()
|
||||
return 1
|
||||
except:
|
||||
return 0
|
|
@ -1,8 +1,10 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# Nga: a Virtual Machine
|
||||
# Copyright (c) 2010 - 2020, Charles Childers
|
||||
#
|
||||
# Copyright (c) 2010 - 2021, Charles Childers
|
||||
# Floating Point I/O by Arland Childers, (c) 2020
|
||||
# Pythonista UI support by Arland Childers, (c) 2021
|
||||
# Optimizations and process() rewrite by Greg Copeland
|
||||
# -------------------------------------------------------------
|
||||
# This implementation of the VM differs from the reference
|
||||
|
@ -36,6 +38,20 @@ from IntegerStack import IntegerStack
|
|||
from Memory import Memory
|
||||
from InitialImage import InitialImage
|
||||
|
||||
from BenchmarkDevice import BenchmarkDevice
|
||||
|
||||
# -------------------------------------------------------------
|
||||
# To Support Python 2.x
|
||||
# -------------------------------------------------------------
|
||||
|
||||
from sys import version_info
|
||||
if version_info.major == 3:
|
||||
pass
|
||||
elif version_info.major == 2:
|
||||
try:
|
||||
input = raw_input
|
||||
except NameError:
|
||||
pass
|
||||
|
||||
class Retro:
|
||||
def map_in(self, name):
|
||||
|
|
Loading…
Reference in a new issue