尝试通过CPU(即不通过DMA)重复读取大数据.喜欢:
int main() {
const int size = 20*1024*1024; // Allocate 20M. Set much larger then L2
char *c = (char *)malloc(size);
for (int i = 0; i < 0xffff; i++)
for (int j = 0; j < size; j++)
c[j] = i*j;
}
Run Code Online (Sandbox Code Playgroud)
但是依赖于服务器更大的问题可能是磁盘缓存(在内存中)然后是L1/L2缓存.在Linux上(例如)使用drop:
sync
echo 3 > /proc/sys/vm/drop_caches
Run Code Online (Sandbox Code Playgroud)
编辑:生成无效的大型程序是微不足道的:
#!/usr/bin/ruby
puts "main:"
200000.times { puts " nop" }
puts " xor rax, rax"
puts " ret"
Run Code Online (Sandbox Code Playgroud)
以不同的名称运行几次(代码不是由脚本生成)应该完成工作
| 归档时间: |
|
| 查看次数: |
24944 次 |
| 最近记录: |