c - 缓存似乎无效
问题描述
我要测试Cache的作用?我发现缓存似乎没有效果。
unsigned time1, time2;
int num=1;
int junk=0;
_mm_clflush(&num);
time1 = __rdtscp((unsigned int*)&junk);
num=2;
time2 = __rdtscp((unsigned int*)&junk) ;
printf("%u\n",(time2-time1));
此代码的输出为 59。
unsigned time1, time2;
int num=1;
int junk=0;
//_mm_clflush(&num);
num=3;
time1 = __rdtscp((unsigned int*)&junk);
num=2;
time2 = __rdtscp((unsigned int*)&junk) ;
printf("%u\n",(time2-time1));
这段代码的输出也是59。第一个代码中的num变量不在缓存中,而第二个在缓存中。为什么时间一样?
解决方案
推荐阅读
- f# - FSharp.Data HTTP 实用程序 RequestString 响应正文前面带有“文本”一词
- r - 我可以使用列表中引用的名称保存 tmap 文件吗?
- json - Python代码展平嵌套的json以获取多条记录
- firebase - Flutter - 在 Firebase 中存储小部件?
- r - 如何在 R> 中使用双 y 轴将图例添加到 ggplot
- django - Django——复杂的上下文还是复杂的模板?
- spring-boot - 将 Spring Integration Router 与 Spring Cloud Stream 一起使用
- xslt - XSLT 转换不正确
- scala - Spark/Scala 近似分组
- c# - 转换列表
到 IEnumerable 在 C# 中