如何加快C#中的阵列克隆?

如何加快C#中的阵列克隆?,第1张

概述我正在努力解决 Cult of the Bound Variable问题. 您的一部分问题已经为“古代”通用机器实施了解释器.我已经为他们描述的机器执行了一个口译,现在我正在运行大学提供的测试基准程序. 我的C#实现这个解释器很慢! 我在ANTS分析器中启动了我的程序,以查看减速的位置,我可以看到,超过96%的时间被“加载程序” *** 作所占用. 该 *** 作符的specification如下: #12. L 我正在努力解决 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;

我的整个“通用机器”口译的源代码是here.

我能做些什么来做得更快?此解释器还有其他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;
总结

以上是内存溢出为你收集整理的如何加快C#中的阵列克隆?全部内容,希望文章能够帮你解决如何加快C#中的阵列克隆?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/langs/1239733.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-06
下一篇 2022-06-06

发表评论

登录后才能评论

评论列表(0条)

保存