From 7592fdd0fd573406b350b36c6ee79ce327eaf99e Mon Sep 17 00:00:00 2001 From: xiao0yy Date: Fri, 15 Oct 2021 16:56:54 +0800 Subject: [PATCH] Reduce the execution time of top command --- scripts/cpu_info.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cpu_info.sh b/scripts/cpu_info.sh index b96e69e..0cd396b 100755 --- a/scripts/cpu_info.sh +++ b/scripts/cpu_info.sh @@ -9,7 +9,7 @@ get_percent() { case $(uname -s) in Linux) - percent=$(LC_NUMERIC=en_US.UTF-8 top -bn2 -p 1 | grep "Cpu(s)" | tail -1 | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}') + percent=$(LC_NUMERIC=en_US.UTF-8 top -bn2 -d 0.01 | grep "Cpu(s)" | tail -1 | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}') normalize_percent_len $percent ;;