赞
踩
以下可一秒800万
.
module strategy;
int run(byte[] a, byte[] b) {
int sum = 0;
for(size_t i; i < a.length; i += 64) {
static foreach(j; 0 .. 64) {
sum += cast(short)a[i + j] * cast(short)b[i + j];
}
}
return sum;
}
而如下,用ldc
可700万
:
module strategy;
int run(byte[] a, byte[] b) {
assert(a.length == b.length);
int sum = 0;
foreach(i; 0 .. a.length) {
sum += cast(short)a[i] * cast(short)b[i];
}
return sum;
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。