Skip to content

Instantly share code, notes, and snippets.

View Nafees10's full-sized avatar

Nafees Hassan Nafees10

  • Lahore, Punjab, Pakistan
  • 02:32 (UTC +05:00)
View GitHub Profile
@Nafees10
Nafees10 / badvm.d
Created October 24, 2019 21:24
2 janky "VM"s to test if using switch-case is better than function calls to call instructions
import std.stdio;
import std.datetime.stopwatch;
void main(string[] args){
FCall caller;
Switcher swExec;
StopWatch sw;
if (args.hasElement("output")){
caller = new FCall(cast(ubyte[])outputProgramInstructions, cast(int[])outputProgramArgs, 64);
swExec = new Switcher(cast(ubyte[])outputProgramInstructions, cast(int[])outputProgramArgs, 64);
module baseConv;
import std.math;
//import misc;
private ulong toDenary(ubyte fromBase, ubyte[] dat){
ulong r = 0, i = 0;
foreach_reverse(cur; dat){
r += pow(fromBase,i)*cur;
i++;