Add performance tests for 6502 implementations #42
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are currently 5 CPU implementations:
jscpu6502.js
: The original JS implementation ofcpu6502
.tscpu6502.ts
: The initial Typescript conversion of the JS implementation usingbind
.tscpu6502v2.ts
: A Typescript version that usescall
instead ofbind
.tscpu6502v5.ts
: A Typescript version that uses a giant switch statement andthis
instead of an array. (Only emulates the 6502.)tscpu6502v6.ts
: A Typescript version using class variables from PR Use class fields instead of binding #40.The performance tests added by this change use the following methodology:
Results include:
The CPU implementations live in
test/perf/impl
. Tests for the implementations live intest
(though not all implementations have tests).To run the tests using Node's
http-server
:then navigate to http://localhost:8080/test/perf/cpu_benchmark.html.
Note that there is plenty of room for improvement in both the benchmark implementation and the measurements.
Here are the results for an example run in Chrome 86 comparing the original JS version, the Typescript version using
bind
and the version from PR #40: