In #26, Scott raised the possibility of adding some query slots to the VM for benchmarking purposes.
I'd prefer to have a separate benchmarking device for VM's that support this.
Proposal:
Add an optional I/O device that provides for additional introspection and timing as an aid to benchmarking and statistics gathering.
Based on Scott's suggestions, this should provide:
There should probably also be some functionality to reset the instruction counts and enable/disable tracking of instruction usage to reduce overhead when not benchmarking.
#Basic Information
An initial outline for the I/O device for benchmarking/profiling
Device ID: TBD
Device #: TBD
This device provides additional introspection and functionality for those who need to profile and benchmark code.
#Operations
#Level 0
This reflects the minimal level of functionality to be considered useful.
0: Execute Function
Stack: count-address function-address -- time-delta
Runs the code at the specified address. When done, store the instruction usage counts in memory, starting at the specified address. This will need 30 cells of memory for the returned values.
This will return a value on the stack indicating the amount of time taken to run the function.
1: Timer Resolution
Stack: -- value
Return a number representing the resolution of the system timer
I'm tentatively planning to implement level 0 as an option for the C and Python VM implementations after 2021.1; and will work on additional functionality after this is done.