iostat 是 i/o statictics 输入输出统计
apt install sysstat
iostat -u
解析:
pidstat -r
解析:
pidstat -d
解析:
pidstat -w
解析:
解析:
/**
* @version 1.0
* @author: mousycoder
* @date: 2019-07-18 17:06
*/
public class HoldCPUMain {
public static class HoldCPUTask implements Runnable{
@Override
public void run() {
while (true){
double a = Math.random() * Math.random();
}
}
}
public static class LazyTask implements Runnable{
@Override
public void run() {
try {
while (true){
Thread.sleep(1000);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
new Thread(new HoldCPUTask()).start();
new Thread(new LazyTask()).start();
new Thread(new LazyTask()).start();
new Thread(new LazyTask()).start();
}
}
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* @version 1.0
* @author: mousycoder
* @date: 2019-07-18 17:06
*/
public class HoldIOMain {
public static class HoldIOTask implements Runnable {
@Override
public void run() {
while (true) {
try {
FileOutputStream fos = new FileOutputStream(new File("temp"));
for (int i = 0; i < 10000; i++) {
fos.write(i);
}
fos.close();
FileInputStream fis = new FileInputStream(new File("temp"));
while (fis.read() != -1) {
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public static class LazyTask implements Runnable{
@Override
public void run() {
try {
while (true) {
Thread.sleep(1000);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
new Thread(new HoldIOTask()).start();
new Thread(new LazyTask()).start();
new Thread(new LazyTask()).start();
new Thread(new LazyTask()).start();
}
}