Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
陶辉
geektime_distrib_perf
提交
5f2763dd
G
geektime_distrib_perf
项目概览
陶辉
/
geektime_distrib_perf
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
1
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
geektime_distrib_perf
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
5f2763dd
编写于
11月 07, 2019
作者:
R
russelltao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add readme
上级
5bde8dc4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
157 addition
and
88 deletion
+157
-88
1-cpu_cache/branch_predict/README.md
1-cpu_cache/branch_predict/README.md
+53
-0
1-cpu_cache/cpu_migrate/README.md
1-cpu_cache/cpu_migrate/README.md
+103
-0
1-cpu_cache/traverse_1d_array/README.md
1-cpu_cache/traverse_1d_array/README.md
+1
-48
1-cpu_cache/traverse_1d_array/traverse_1d_array.java
1-cpu_cache/traverse_1d_array/traverse_1d_array.java
+0
-40
未找到文件。
1-cpu_cache/branch_predict/README.md
0 → 100644
浏览文件 @
5f2763dd
## 1. 验证环境
*
操作系统: CentOS7.0
*
CPU: Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz
*
GCC-C++: 4.8.5
*
JAVA: 1.8.0
*
Python: 2.7.5
## 2. C++程序branch_predict.cpp
### a. 编译程序
#### 安装编译依赖的软件
如Linux中需要安装gcc-c++,CentOS中可用
`yum install gcc-c++`
安装,Ubuntu中可用
`apt-get install gcc-c++`
#### 编译程序
`g++ branch_predict.cpp -o branch_predict`
### b. 运行验证
#### 准备随机数组与排序好的数组
`./branch_predict -g`
该命令会在当前目录下生成随机数组rand.array文件和有序数组sort.array文件
#### 遍历随机数组
`./branch_predict -s`
消耗时间(毫秒):1000
#### 遍历有序数组
`./branch_predict -f`
消耗时间(毫秒):350
#### 遍历随机数组
`perf stat -e cache-references,cache-misses,instructions,cycles,L1-dcache-load-misses,L1-dcache-loads ./branch_predict -`
```
Performance counter stats for './branch_predict -s':
1,504,222,463 instructions # 0.49 insn per cycle
3,084,103,065 cycles
84,992 L1-icache-load-misses
67,153,573 branch-load-misses
273,893,334 branch-loads
1.040296121 seconds time elapsed
0.987243000 seconds user
0.053060000 seconds sys
```
#### 遍历有序数组
`perf stat -e cache-references,cache-misses,instructions,cycles,L1-dcache-load-misses,L1-dcache-loads ./branch_predict -f`
*
输出结果:
```
1,501,478,360 instructions # 1.27 insn per cycle
1,180,637,963 cycles
49,351 L1-icache-load-misses
27,282 branch-load-misses
273,404,227 branch-loads
0.404512198 seconds time elapsed
0.352686000 seconds user
0.051845000 seconds sys
```
1-cpu_cache/cpu_migrate/README.md
0 → 100644
浏览文件 @
5f2763dd
## 1. 验证环境
*
操作系统: CentOS7.0
*
CPU: Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz
*
GCC-C++: 4.8.5
*
JAVA: 1.8.0
*
Python: 2.7.5
## 2. C++程序traverse_2d_array.cpp
### a. 编译程序
#### 安装编译依赖的软件
如Linux中需要安装gcc-c++,CentOS中可用
`yum install gcc-c++`
安装,Ubuntu中可用
`apt-get install gcc-c++`
#### 编译程序
`g++ traverse_2d_array.cpp -o traverse_2d_array`
### b. 运行验证
#### 使用array[i][j]遍历数组
`./traverse_2d_array -f`
消耗时间(毫秒):10
#### 使用array[j][i]遍历数组
`./traverse_2d_array -s`
消耗时间(毫秒):70
### c. 使用perf验证缓存命中率
#### 使用array[i][j]遍历数组
`perf stat -e cache-references,cache-misses,instructions,cycles,L1-dcache-load-misses,L1-dcache-loads ./traverse_2d_array -f`
*
输出结果:
```
Performance counter stats for './traverse_2d_array -f':
147,927 cache-references (80.14%)
13,215 cache-misses # 8.933 % of all cache refs (65.49%)
54,454,827 instructions # 1.43 insn per cycle (85.11%)
38,197,267 cycles (85.09%)
161,503 L1-dcache-load-misses # 0.90% of all L1-dcache hits (85.09%)
18,035,307 L1-dcache-loads (84.19%)
0.020651344 seconds time elapsed
0.018625000 seconds user
0.002069000 seconds sys
```
#### 使用array[j][i]遍历数组
`perf stat -e cache-references,cache-misses,instructions,cycles,L1-dcache-load-misses,L1-dcache-loads ./traverse_2d_array -s`
*
输出结果:
```
Performance counter stats for './traverse_2d_array -s':
4,341,186 cache-references (83.01%)
13,974 cache-misses # 0.322 % of all cache refs (66.03%)
55,245,646 instructions # 0.25 insn per cycle (83.01%)
218,787,967 cycles (83.00%)
4,308,394 L1-dcache-load-misses # 23.79% of all L1-dcache hits (83.86%)
18,112,753 L1-dcache-loads (84.10%)
0.082950118 seconds time elapsed
0.079066000 seconds user
0.003953000 seconds sys
```
## 3. Java程序
### a. 编译程序
`javac traverse_2d_array.java`
### b.运行验证
#### 使用array[i][j]遍历数组
`java traverse_2d_array -f`
消耗时间(毫秒):20
#### 使用array[j][i]遍历数组
`java traverse_2d_array -s`
消耗时间(毫秒):100
### c. 使用perf验证缓存命中率
#### 使用array[i][j]遍历数组
`perf stat -e cache-references,cache-misses,instructions,cycles,L1-dcache-load-misses,L1-dcache-loads ./traverse_2d_array -f`
*
输出结果:
```
Performance counter stats for 'java traverse_2d_array -f':
6,379,138 cache-references (80.62%)
866,578 cache-misses # 13.585 % of all cache refs (68.93%)
459,726,039 instructions # 1.51 insn per cycle (85.22%)
303,673,757 cycles (85.69%)
5,270,707 L1-dcache-load-misses # 3.96% of all L1-dcache hits (81.64%)
133,211,743 L1-dcache-loads (83.13%)
0.126089887 seconds time elapsed
0.122353000 seconds user
0.047877000 seconds sys
```
#### 使用array[j][i]遍历数组
`perf stat -e cache-references,cache-misses,instructions,cycles,L1-dcache-load-misses,L1-dcache-loads ./traverse_2d_array -s`
*
输出结果:
```
Performance counter stats for 'java traverse_2d_array -s':
42,441,956 cache-references (80.21%)
872,336 cache-misses # 2.055 % of all cache refs (66.61%)
386,326,280 instructions # 0.71 insn per cycle (84.29%)
544,411,061 cycles (85.01%)
38,884,991 L1-dcache-load-misses # 32.48% of all L1-dcache hits (85.24%)
119,711,464 L1-dcache-loads (82.94%)
0.192838747 seconds time elapsed
0.200693000 seconds user
0.052919000 seconds sys
```
\ No newline at end of file
1-cpu_cache/traverse_1d_array/README.md
浏览文件 @
5f2763dd
...
...
@@ -31,7 +31,7 @@
26,230 cache-misses # 7.882 % of all cache refs (67.17%)
111,702,471 instructions # 1.61 insn per cycle (83.59%)
69,498,357 cycles (83.57%)
** 250,109 L1-dcache-load-misses # 0.43% of all L1-dcache hits (83.58%) **
250,109 L1-dcache-load-misses # 0.43% of all L1-dcache hits (83.58%)
58,115,659 L1-dcache-loads (82.72%)
0.030938059 seconds time elapsed
...
...
@@ -71,51 +71,4 @@
0.158064000 seconds user
1.736704000 seconds sys
```
## 3. Java程序
### a. 编译程序
`javac traverse_1d_array.java`
### b.运行验证
#### 使用array[i][j]遍历数组
`java traverse_1d_array -f`
消耗时间(毫秒):20
#### 使用array[j][i]遍历数组
`java traverse_1d_array -s`
消耗时间(毫秒):100
### c. 使用perf验证缓存命中率
#### 使用array[i][j]遍历数组
`perf stat -e cache-references,cache-misses,instructions,cycles,L1-dcache-load-misses,L1-dcache-loads ./traverse_1d_array -f`
*
输出结果:
```
Performance counter stats for 'java traverse_2d_array -f':
6,379,138 cache-references (80.62%)
866,578 cache-misses # 13.585 % of all cache refs (68.93%)
459,726,039 instructions # 1.51 insn per cycle (85.22%)
303,673,757 cycles (85.69%)
5,270,707 L1-dcache-load-misses # 3.96% of all L1-dcache hits (81.64%)
133,211,743 L1-dcache-loads (83.13%)
0.126089887 seconds time elapsed
0.122353000 seconds user
0.047877000 seconds sys
```
#### 使用array[j][i]遍历数组
`perf stat -e cache-references,cache-misses,instructions,cycles,L1-dcache-load-misses,L1-dcache-loads ./traverse_1d_array -s`
*
输出结果:
```
Performance counter stats for 'java traverse_2d_array -s':
42,441,956 cache-references (80.21%)
872,336 cache-misses # 2.055 % of all cache refs (66.61%)
386,326,280 instructions # 0.71 insn per cycle (84.29%)
544,411,061 cycles (85.01%)
38,884,991 L1-dcache-load-misses # 32.48% of all L1-dcache hits (85.24%)
119,711,464 L1-dcache-loads (82.94%)
0.192838747 seconds time elapsed
0.200693000 seconds user
0.052919000 seconds sys
```
\ No newline at end of file
1-cpu_cache/traverse_1d_array/traverse_1d_array.java
已删除
100644 → 0
浏览文件 @
5bde8dc4
import
java.util.Date
;
public
class
traverse_1d_array
{
public
static
void
main
(
String
args
[]){
int
ch
;
int
TESTN
=
4096
;
boolean
slowMode
=
false
;
for
(
String
arg
:
args
)
{
if
(
"-f"
.
equals
(
arg
))
{
slowMode
=
false
;
break
;
}
else
if
(
"-s"
.
equals
(
arg
))
{
slowMode
=
true
;
break
;
}
}
char
[][]
arr
=
new
char
[
TESTN
][
TESTN
];
Date
start
=
new
Date
();
if
(!
slowMode
)
{
for
(
int
i
=
0
;
i
<
TESTN
;
i
++)
{
for
(
int
j
=
0
;
j
<
TESTN
;
j
++)
{
//arr[i][j]是连续访问的
arr
[
i
][
j
]
=
0
;
}
}
}
else
{
for
(
int
i
=
0
;
i
<
TESTN
;
i
++)
{
for
(
int
j
=
0
;
j
<
TESTN
;
j
++)
{
//arr[j][i]是不连续访问的
arr
[
j
][
i
]
=
0
;
}
}
}
System
.
out
.
println
(
new
Date
().
getTime
()-
start
.
getTime
());
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录