判断cache Line的作用

/*求一个二维数组每一列的和,用以测试计算机使用cache line方法后采用不同编写方式所带来的程序运行时间的差异*/
#include<iostream>
#include <time.h>
using namespace std;
int main() {
//初始化
int I = 10000, J = 10000, i = 0, j = 0;
int **d = new int*[I];
int * clomun = new int[I];
for (i = 0; i < I; i++) {
d[i] = new int[I];
for (j = 0; j < J; j++) {
d[i][j] = 1;
}
}
//按列取值
int start = clock(), end = 0;
for (j = 0; j <J; j++) {
clomun[j] = 0;
for (i = 0; i < I; i++)
clomun[j] += d[i][j];
}
end = clock();
cout << "按照列取值耗时为:" << end - start << endl;
//按行取值
start = clock(), end = 0;
for (i = 0; i < I; i++)
clomun[i] = 0;
for (i = 0; i < I; i++) {
for (j = 0; j <J; j++)
clomun[j]+= d[i][j];
}
end = clock();
cout << "按照行取值耗时为:" << end - start << endl;
return 0;
}

转载于:https://www.cnblogs.com/1996313xjf/p/6399101.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
declare tName varchar2(1000); str varchar2(1000); cou number; indexStart number; begin tName:= 'Docdetail'; str:= 'select count(*) as int from tab where tname=upper('''|| tName||''')' ; dbms_output.put_line(str); execute immediate str into cou ; if cou>0 then begin str:= 'select nvl(max(id),0)+1000 from ' || tName ; execute immediate str into indexStart ; str:='create sequence ' || tName || '_id start with '|| indexStart ||' increment by 1 nomaxvalue nocache'; dbms_output.put_line(str); execute immediate str; end; end if ; end; / declare tName varchar2(1000); str varchar2(1000); cou number; indexStart number; begin tName:= 'ImageFile'; str:= 'select count(*) as int from tab where tname=upper('''|| tName||''')' ; dbms_output.put_line(str); execute immediate str into cou ; if cou>0 then begin str:= 'select nvl(max(imagefileid),0)+1000 from ' || tName ; execute immediate str into indexStart ; str:='create sequence ' || tName || '_id start with '|| indexStart ||' increment by 1 nomaxvalue nocache'; dbms_output.put_line(str); execute immediate str; end; end if ; end; / declare tName varchar2(1000); str varchar2(1000); cou number; indexStart number; begin tName:= 'docImageFile'; str:= 'select count(*) as int from tab where tname=upper('''|| tName||''')' ; dbms_output.put_line(str); execute immediate str into cou ; if cou>0 then begin str:= 'select nvl(max(id),0)+1000 from ' || tName ; execute immediate str into indexStart ; str:='create sequence ' || tName || '_id2 start with '|| indexStart ||' increment by 1 nomaxvalue nocache'; dbms_output.put_line(str); execute immediate str; end; end if ; end; / 这个sql是干嘛的
06-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值