mmc*_*ole 10 .net c# performance interpreter
我正在研究我对绑定变量问题的解决方案.
部分问题是你为"古代"通用机器实现了一个解释器.我已经为他们描述的机器实现了一个解释器,现在我正在运行一个大学提供的测试它的基准程序.
我的这个解释器的C#实现很慢!
我在ANTS分析器中启动了我的程序以查看减速的位置,我可以看到超过96%的时间被"加载程序"操作占用.

该运算符的规范如下:
#12. Load Program.
The array identified by the B register is duplicated
and the duplicate shall replace the '0' array,
regardless of size. The execution finger is placed
to indicate the platter of this array that is
described by the offset given in C, where the value
0 denotes the first platter, 1 the second, et
cetera.
The '0' array shall be the most sublime choice for
loading, and shall be handled with the utmost
velocity.
Run Code Online (Sandbox Code Playgroud)
这是我的运算符的代码:
case 12: // Load Program
_platters[0] = (UInt32[])_platters[(int)_registers[B]].Clone();
_finger = _registers[C];
break;
Run Code Online (Sandbox Code Playgroud)
我的整个"通用机器"解释器的源代码就在这里.
我能做些什么来加快速度?这个解释器的其他实现用C语言编写,可以更快地完成整个基准测试.
你可以尝试使用Buffer.BlockCopy,虽然如果它在这种情况下产生任何巨大的差异我会感到惊讶:
case 12: // Load Program
uint[] src = _platters[(int)_registers[B]];
_platters[0] = new uint[src.Length];
Buffer.BlockCopy(src, 0, _platters[0], 0, src.Length * 4);
_finger = _registers[C];
break;
Run Code Online (Sandbox Code Playgroud)