mirror of
https://github.com/yanfeizhang/coder-kung-fu.git
synced 2026-05-05 09:35:07 +08:00
feat:添加磁盘性能测试实验
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.DS_Store
|
||||
*.zip
|
||||
91
tests/disk/test01/randread.fio
Executable file
91
tests/disk/test01/randread.fio
Executable file
@@ -0,0 +1,91 @@
|
||||
[global]
|
||||
ioengine=libaio
|
||||
direct=1
|
||||
filename=/search/odin/test.log
|
||||
size=100G
|
||||
ioscheduler=noop
|
||||
refill_buffers
|
||||
unified_rw_reporting=0
|
||||
time_based
|
||||
runtime=300
|
||||
|
||||
[test-randrandread-512]
|
||||
ioengine=libaio
|
||||
rw=randread
|
||||
bs=512b
|
||||
|
||||
[test-randread-1k]
|
||||
ioengine=libaio
|
||||
rw=randread
|
||||
bs=1k
|
||||
|
||||
[test-randread-2k]
|
||||
ioengine=libaio
|
||||
rw=randread
|
||||
bs=2k
|
||||
|
||||
[test-randread-4k]
|
||||
ioengine=libaio
|
||||
rw=randread
|
||||
bs=4k
|
||||
|
||||
[test-randread-8k]
|
||||
ioengine=libaio
|
||||
rw=randread
|
||||
bs=8k
|
||||
|
||||
[test-randread-16k]
|
||||
ioengine=libaio
|
||||
rw=randread
|
||||
bs=16k
|
||||
|
||||
[test-randread-32k]
|
||||
ioengine=libaio
|
||||
rw=randread
|
||||
bs=32k
|
||||
|
||||
[test-randread-64k]
|
||||
ioengine=libaio
|
||||
rw=randread
|
||||
bs=64k
|
||||
|
||||
[test-randread-128k]
|
||||
ioengine=libaio
|
||||
rw=randread
|
||||
bs=128k
|
||||
|
||||
[test-randread-256k]
|
||||
ioengine=libaio
|
||||
rw=randread
|
||||
bs=256k
|
||||
|
||||
[test-randread-1m]
|
||||
ioengine=libaio
|
||||
rw=randread
|
||||
bs=1m
|
||||
|
||||
[test-randread-2m]
|
||||
ioengine=libaio
|
||||
rw=randread
|
||||
bs=2m
|
||||
|
||||
[test-randread-4m]
|
||||
ioengine=libaio
|
||||
rw=randread
|
||||
bs=4m
|
||||
|
||||
[test-randread-8m]
|
||||
ioengine=libaio
|
||||
rw=randread
|
||||
bs=8m
|
||||
|
||||
[test-randread-16m]
|
||||
ioengine=libaio
|
||||
rw=randread
|
||||
bs=16m
|
||||
|
||||
[test-randread-32m]
|
||||
ioengine=libaio
|
||||
rw=randread
|
||||
bs=32m
|
||||
|
||||
64
tests/disk/test01/randread.php
Executable file
64
tests/disk/test01/randread.php
Executable file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
class FioTest {
|
||||
|
||||
private $_in = "randread.fio";
|
||||
private $_out = "data/randread_total";
|
||||
|
||||
public function run(){
|
||||
file_put_contents($this->_out, "");
|
||||
|
||||
$sections = $this->getSections($this->_in);
|
||||
foreach($sections as $sec){
|
||||
$fioResult = $this->runFioTest($sec);
|
||||
file_put_contents("data/".$sec, $fioResult);
|
||||
$res = $this->parseFioResult($fioResult);
|
||||
|
||||
$line = $sec."\t".$res['bw']."\t".$res['lat']."\t".$res['iops']."\n";
|
||||
echo $line;
|
||||
file_put_contents($this->_out, $line, FILE_APPEND);
|
||||
sleep(60);
|
||||
}
|
||||
}
|
||||
|
||||
public function parseFioResult($fioResult){
|
||||
$result = array();
|
||||
$fio = json_decode($fioResult, true);
|
||||
$result['iops'] = $fio["jobs"][0]['read']['iops_mean'];
|
||||
$result['bw'] = $fio["jobs"][0]['read']['bw_mean']; //kb
|
||||
$result['lat'] = $fio["jobs"][0]['read']["lat_ns"]['mean']; //ns
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function runFioTest($section){
|
||||
$cmd = "fio ".$this->_in." --section=".$section." --output-format=json";
|
||||
echo $cmd."\n";
|
||||
$result = shell_exec($cmd);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getSections($fioFile){
|
||||
$matches = array();
|
||||
$contents = file_get_contents($fioFile);
|
||||
$pattern = '/\[(.+)\]/';
|
||||
preg_match_all($pattern, $contents, $matches);
|
||||
|
||||
$secs = array();
|
||||
foreach($matches[1] as $sec){
|
||||
if($sec=="global"){
|
||||
continue;
|
||||
}
|
||||
$secs[] = $sec;
|
||||
}
|
||||
return $secs;
|
||||
}
|
||||
}
|
||||
|
||||
$test = new FioTest();
|
||||
$test->run();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
95
tests/disk/test01/randwrite.fio
Executable file
95
tests/disk/test01/randwrite.fio
Executable file
@@ -0,0 +1,95 @@
|
||||
[global]
|
||||
ioengine=libaio
|
||||
direct=1
|
||||
filename=/search/odin/test.log
|
||||
size=100G
|
||||
ioscheduler=noop
|
||||
refill_buffers
|
||||
unified_rw_reporting=0
|
||||
time_based
|
||||
runtime=300
|
||||
|
||||
[test-randwrite-512]
|
||||
ioengine=libaio
|
||||
rw=randwrite
|
||||
bs=512b
|
||||
|
||||
[test-randwrite-1k]
|
||||
ioengine=libaio
|
||||
rw=randwrite
|
||||
bs=1k
|
||||
|
||||
[test-randwrite-2k]
|
||||
ioengine=libaio
|
||||
rw=randwrite
|
||||
bs=2k
|
||||
|
||||
[test-randwrite-4k]
|
||||
ioengine=libaio
|
||||
rw=randwrite
|
||||
bs=4k
|
||||
|
||||
[test-randwrite-8k]
|
||||
ioengine=libaio
|
||||
rw=randwrite
|
||||
bs=8k
|
||||
|
||||
[test-randwrite-16k]
|
||||
ioengine=libaio
|
||||
rw=randwrite
|
||||
bs=16k
|
||||
|
||||
[test-randwrite-32k]
|
||||
ioengine=libaio
|
||||
rw=randwrite
|
||||
bs=32k
|
||||
|
||||
[test-randwrite-64k]
|
||||
ioengine=libaio
|
||||
rw=randwrite
|
||||
bs=64k
|
||||
|
||||
[test-randwrite-128k]
|
||||
ioengine=libaio
|
||||
rw=randwrite
|
||||
bs=128k
|
||||
|
||||
[test-randwrite-256k]
|
||||
ioengine=libaio
|
||||
rw=randwrite
|
||||
bs=256k
|
||||
|
||||
[test-randwrite-512k]
|
||||
ioengine=libaio
|
||||
rw=randwrite
|
||||
bs=512k
|
||||
|
||||
[test-randwrite-1m]
|
||||
ioengine=libaio
|
||||
rw=randwrite
|
||||
bs=1m
|
||||
|
||||
[test-randwrite-2m]
|
||||
ioengine=libaio
|
||||
rw=randwrite
|
||||
bs=2m
|
||||
|
||||
[test-randwrite-4m]
|
||||
ioengine=libaio
|
||||
rw=randwrite
|
||||
bs=4m
|
||||
|
||||
[test-randwrite-8m]
|
||||
ioengine=libaio
|
||||
rw=randwrite
|
||||
bs=8m
|
||||
|
||||
[test-randwrite-16m]
|
||||
ioengine=libaio
|
||||
rw=randwrite
|
||||
bs=16m
|
||||
|
||||
[test-randwrite-32m]
|
||||
ioengine=libaio
|
||||
rw=randwrite
|
||||
bs=32m
|
||||
64
tests/disk/test01/randwrite.php
Executable file
64
tests/disk/test01/randwrite.php
Executable file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
class FioTest {
|
||||
|
||||
private $_in = "randwrite.fio";
|
||||
private $_out = "data/randwrite_total";
|
||||
|
||||
public function run(){
|
||||
file_put_contents($this->_out, "");
|
||||
|
||||
$sections = $this->getSections($this->_in);
|
||||
foreach($sections as $sec){
|
||||
$fioResult = $this->runFioTest($sec);
|
||||
file_put_contents("data/".$sec, $fioResult);
|
||||
$res = $this->parseFioResult($fioResult);
|
||||
|
||||
$line = $sec."\t".$res['bw']."\t".$res['lat']."\t".$res['iops']."\n";
|
||||
echo $line;
|
||||
file_put_contents($this->_out, $line, FILE_APPEND);
|
||||
sleep(60);
|
||||
}
|
||||
}
|
||||
|
||||
public function parseFioResult($fioResult){
|
||||
$result = array();
|
||||
$fio = json_decode($fioResult, true);
|
||||
$result['iops'] = $fio["jobs"][0]['write']['iops_mean'];
|
||||
$result['bw'] = $fio["jobs"][0]['write']['bw_mean']; //kb
|
||||
$result['lat'] = $fio["jobs"][0]['write']["lat_ns"]['mean']; //ns
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function runFioTest($section){
|
||||
$cmd = "fio ".$this->_in." --section=".$section." --output-format=json";
|
||||
echo $cmd."\n";
|
||||
$result = shell_exec($cmd);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getSections($fioFile){
|
||||
$matches = array();
|
||||
$contents = file_get_contents($fioFile);
|
||||
$pattern = '/\[(.+)\]/';
|
||||
preg_match_all($pattern, $contents, $matches);
|
||||
|
||||
$secs = array();
|
||||
foreach($matches[1] as $sec){
|
||||
if($sec=="global"){
|
||||
continue;
|
||||
}
|
||||
$secs[] = $sec;
|
||||
}
|
||||
return $secs;
|
||||
}
|
||||
}
|
||||
|
||||
$test = new FioTest();
|
||||
$test->run();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
91
tests/disk/test01/read.fio
Executable file
91
tests/disk/test01/read.fio
Executable file
@@ -0,0 +1,91 @@
|
||||
[global]
|
||||
ioengine=libaio
|
||||
direct=1
|
||||
filename=/search/odin/test.log
|
||||
size=100G
|
||||
ioscheduler=noop
|
||||
refill_buffers
|
||||
unified_rw_reporting=0
|
||||
time_based
|
||||
runtime=300
|
||||
|
||||
[test-read-512]
|
||||
ioengine=libaio
|
||||
rw=read
|
||||
bs=512b
|
||||
|
||||
[test-read-1k]
|
||||
ioengine=libaio
|
||||
rw=read
|
||||
bs=1k
|
||||
|
||||
[test-read-2k]
|
||||
ioengine=libaio
|
||||
rw=read
|
||||
bs=2k
|
||||
|
||||
[test-read-4k]
|
||||
ioengine=libaio
|
||||
rw=read
|
||||
bs=4k
|
||||
|
||||
[test-read-8k]
|
||||
ioengine=libaio
|
||||
rw=read
|
||||
bs=8k
|
||||
|
||||
[test-read-16k]
|
||||
ioengine=libaio
|
||||
rw=read
|
||||
bs=16k
|
||||
|
||||
[test-read-32k]
|
||||
ioengine=libaio
|
||||
rw=read
|
||||
bs=32k
|
||||
|
||||
[test-read-64k]
|
||||
ioengine=libaio
|
||||
rw=read
|
||||
bs=64k
|
||||
|
||||
[test-read-128k]
|
||||
ioengine=libaio
|
||||
rw=read
|
||||
bs=128k
|
||||
|
||||
[test-read-256k]
|
||||
ioengine=libaio
|
||||
rw=read
|
||||
bs=256k
|
||||
|
||||
[test-read-1m]
|
||||
ioengine=libaio
|
||||
rw=read
|
||||
bs=1m
|
||||
|
||||
[test-read-2m]
|
||||
ioengine=libaio
|
||||
rw=read
|
||||
bs=2m
|
||||
|
||||
[test-read-4m]
|
||||
ioengine=libaio
|
||||
rw=read
|
||||
bs=4m
|
||||
|
||||
[test-read-8m]
|
||||
ioengine=libaio
|
||||
rw=read
|
||||
bs=8m
|
||||
|
||||
[test-read-16m]
|
||||
ioengine=libaio
|
||||
rw=read
|
||||
bs=16m
|
||||
|
||||
[test-read-32m]
|
||||
ioengine=libaio
|
||||
rw=read
|
||||
bs=32m
|
||||
|
||||
64
tests/disk/test01/read.php
Executable file
64
tests/disk/test01/read.php
Executable file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
class FioTest {
|
||||
|
||||
private $_in = "read.fio";
|
||||
private $_out = "data/read_total";
|
||||
|
||||
public function run(){
|
||||
file_put_contents($this->_out, "");
|
||||
|
||||
$sections = $this->getSections($this->_in);
|
||||
foreach($sections as $sec){
|
||||
$fioResult = $this->runFioTest($sec);
|
||||
file_put_contents("data/".$sec, $fioResult);
|
||||
$res = $this->parseFioResult($fioResult);
|
||||
|
||||
$line = $sec."\t".$res['bw']."\t".$res['lat']."\t".$res['iops']."\n";
|
||||
echo $line;
|
||||
file_put_contents($this->_out, $line, FILE_APPEND);
|
||||
sleep(60);
|
||||
}
|
||||
}
|
||||
|
||||
public function parseFioResult($fioResult){
|
||||
$result = array();
|
||||
$fio = json_decode($fioResult, true);
|
||||
$result['iops'] = $fio["jobs"][0]['read']['iops_mean'];
|
||||
$result['bw'] = $fio["jobs"][0]['read']['bw_mean']; //kb
|
||||
$result['lat'] = $fio["jobs"][0]['read']["lat_ns"]['mean']; //ns
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function runFioTest($section){
|
||||
$cmd = "fio ".$this->_in." --section=".$section." --output-format=json";
|
||||
echo $cmd."\n";
|
||||
$result = shell_exec($cmd);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getSections($fioFile){
|
||||
$matches = array();
|
||||
$contents = file_get_contents($fioFile);
|
||||
$pattern = '/\[(.+)\]/';
|
||||
preg_match_all($pattern, $contents, $matches);
|
||||
|
||||
$secs = array();
|
||||
foreach($matches[1] as $sec){
|
||||
if($sec=="global"){
|
||||
continue;
|
||||
}
|
||||
$secs[] = $sec;
|
||||
}
|
||||
return $secs;
|
||||
}
|
||||
}
|
||||
|
||||
$test = new FioTest();
|
||||
$test->run();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
95
tests/disk/test01/write.fio
Executable file
95
tests/disk/test01/write.fio
Executable file
@@ -0,0 +1,95 @@
|
||||
[global]
|
||||
ioengine=libaio
|
||||
direct=1
|
||||
filename=/search/odin/test.log
|
||||
size=100G
|
||||
ioscheduler=noop
|
||||
refill_buffers
|
||||
unified_rw_reporting=0
|
||||
time_based
|
||||
runtime=300
|
||||
|
||||
[test-write-512]
|
||||
ioengine=libaio
|
||||
rw=write
|
||||
bs=512b
|
||||
|
||||
[test-write-1k]
|
||||
ioengine=libaio
|
||||
rw=write
|
||||
bs=1k
|
||||
|
||||
[test-write-2k]
|
||||
ioengine=libaio
|
||||
rw=write
|
||||
bs=2k
|
||||
|
||||
[test-write-4k]
|
||||
ioengine=libaio
|
||||
rw=write
|
||||
bs=4k
|
||||
|
||||
[test-write-8k]
|
||||
ioengine=libaio
|
||||
rw=write
|
||||
bs=8k
|
||||
|
||||
[test-write-16k]
|
||||
ioengine=libaio
|
||||
rw=write
|
||||
bs=16k
|
||||
|
||||
[test-write-32k]
|
||||
ioengine=libaio
|
||||
rw=write
|
||||
bs=32k
|
||||
|
||||
[test-write-64k]
|
||||
ioengine=libaio
|
||||
rw=write
|
||||
bs=64k
|
||||
|
||||
[test-write-128k]
|
||||
ioengine=libaio
|
||||
rw=write
|
||||
bs=128k
|
||||
|
||||
[test-write-256k]
|
||||
ioengine=libaio
|
||||
rw=write
|
||||
bs=256k
|
||||
|
||||
[test-write-512k]
|
||||
ioengine=libaio
|
||||
rw=write
|
||||
bs=512k
|
||||
|
||||
[test-write-1m]
|
||||
ioengine=libaio
|
||||
rw=write
|
||||
bs=1m
|
||||
|
||||
[test-write-2m]
|
||||
ioengine=libaio
|
||||
rw=write
|
||||
bs=2m
|
||||
|
||||
[test-write-4m]
|
||||
ioengine=libaio
|
||||
rw=write
|
||||
bs=4m
|
||||
|
||||
[test-write-8m]
|
||||
ioengine=libaio
|
||||
rw=write
|
||||
bs=8m
|
||||
|
||||
[test-write-16m]
|
||||
ioengine=libaio
|
||||
rw=write
|
||||
bs=16m
|
||||
|
||||
[test-write-32m]
|
||||
ioengine=libaio
|
||||
rw=write
|
||||
bs=32m
|
||||
64
tests/disk/test01/write.php
Executable file
64
tests/disk/test01/write.php
Executable file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
class FioTest {
|
||||
|
||||
private $_in = "write.fio";
|
||||
private $_out = "data/write_total";
|
||||
|
||||
public function run(){
|
||||
file_put_contents($this->_out, "");
|
||||
|
||||
$sections = $this->getSections($this->_in);
|
||||
foreach($sections as $sec){
|
||||
$fioResult = $this->runFioTest($sec);
|
||||
file_put_contents("data/".$sec, $fioResult);
|
||||
$res = $this->parseFioResult($fioResult);
|
||||
|
||||
$line = $sec."\t".$res['bw']."\t".$res['lat']."\t".$res['iops']."\n";
|
||||
echo $line;
|
||||
file_put_contents($this->_out, $line, FILE_APPEND);
|
||||
sleep(60);
|
||||
}
|
||||
}
|
||||
|
||||
public function parseFioResult($fioResult){
|
||||
$result = array();
|
||||
$fio = json_decode($fioResult, true);
|
||||
$result['iops'] = $fio["jobs"][0]['write']['iops_mean'];
|
||||
$result['bw'] = $fio["jobs"][0]['write']['bw_mean']; //kb
|
||||
$result['lat'] = $fio["jobs"][0]['write']["lat_ns"]['mean']; //ns
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function runFioTest($section){
|
||||
$cmd = "fio ".$this->_in." --section=".$section." --output-format=json";
|
||||
echo $cmd."\n";
|
||||
$result = shell_exec($cmd);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getSections($fioFile){
|
||||
$matches = array();
|
||||
$contents = file_get_contents($fioFile);
|
||||
$pattern = '/\[(.+)\]/';
|
||||
preg_match_all($pattern, $contents, $matches);
|
||||
|
||||
$secs = array();
|
||||
foreach($matches[1] as $sec){
|
||||
if($sec=="global"){
|
||||
continue;
|
||||
}
|
||||
$secs[] = $sec;
|
||||
}
|
||||
return $secs;
|
||||
}
|
||||
}
|
||||
|
||||
$test = new FioTest();
|
||||
$test->run();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
17
tests/index.md
Normal file
17
tests/index.md
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
## CPU相关实验
|
||||
- [likely 和 unlikely 汇编结果对比](tests/cpu/test01)
|
||||
|
||||
## 磁盘相关实验
|
||||
- [使用fio磁盘压测工具进行性能压测分析](tests/disk/test01)
|
||||
|
||||
## 网络相关实验
|
||||
- [PHP单语言的百万连接测试源码](tests/network/test01)
|
||||
- [通过多 IP 达成单机百万连接(支持c、java、php三种语言)](tests/network/test02)
|
||||
- [通过端口重用达成单机百万连接(支持c、java、php三种语言)](tests/network/test03)
|
||||
- [一个模拟 tcpdump 的简单抓包程序](tests/network/test04)
|
||||
- [用 bridge 连接本机上的多组 veth,使其可以互相通信](tests/network/test05)
|
||||
- [命令行使用 namespace 的简单实验](tests/network/test06)
|
||||
- [手工模拟实现一个可以和外部通信的容器网络](tests/network/test07)
|
||||
- [socket端口复用SO_REUSEPORT测试](tests/network/test08)
|
||||
|
||||
Reference in New Issue
Block a user