我正在努力解决
Cult of the Bound Variable问题.
您的一部分问题已经为“古代”通用机器实施了解释器.我已经为他们描述的机器执行了一个口译,现在我正在运行大学提供的测试基准程序.
我的C#实现这个解释器很慢!
我在ANTS分析器中启动了我的程序,以查看减速的位置,我可以看到,超过96%的时间被“加载程序”操作所占用.
该操作符的specification如下:
#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.
这是我的这个操作符的代码:
case 12: // Load Program _platters[0] = (UInt32[])_platters[(int)_registers[B]].Clone(); _finger = _registers[C]; break;
我能做些什么来做得更快?此解释器还有其他C语言编写,可以更快地完成整个基准测试.
解决方法
您可以尝试使用
Buffer.BlockCopy
,但如果在这种情况下产生巨大差异,我会感到惊讶:
case 12: // Load Program uint[] src = _platters[(int)_registers[B]]; _platters[0] = new uint[src.Length]; Buffer.Blockcopy(src,_platters[0],src.Length * 4); _finger = _registers[C]; break;
原文地址:https://www.jb51.cc/csharp/97770.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。