Commit 36eea926 authored by Michal Berger's avatar Michal Berger Committed by Tomasz Zawadzki
Browse files

scripts/perf: Allow to define interval for collect-cpu-load



Change-Id: I35d53128dff8cbd0483b9c972f6baf356e46d221
Signed-off-by: default avatarMichal Berger <michal.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/21177


Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 59c811f0
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ help() {
		     indefinitely.
		-d - Directory where results should be saved. Default is /tmp.
		-p - Add prefix to saved files.
		-t - How long to wait before each load read. Default is 1s.

		cpu - Valid cpu id (e.g. 0) to monitor.

@@ -38,10 +39,11 @@ _get_cpu_time() {
}

count=0
interval=1
output_dir=/tmp
prefix=""

while getopts c:d:hp: opt; do
while getopts c:d:hp:t: opt; do
	case "$opt" in
		c) count=$OPTARG ;;
		d) output_dir=$OPTARG ;;
@@ -50,6 +52,7 @@ while getopts c:d:hp: opt; do
			exit 0
			;;
		p) prefix=$OPTARG ;;
		t) interval=$OPTARG ;;
		*) ;;
	esac
done
@@ -62,4 +65,4 @@ mkdir -p "$output_dir"
cpus=("$@")
((${#cpus[@]} > 0)) || cpus=($(get_online_cpus))

_get_cpu_time "$count" "" 1 "${cpus[@]}"
_get_cpu_time "$count" "" 1 "$interval" "${cpus[@]}"
+4 −4
Original line number Diff line number Diff line
@@ -475,8 +475,8 @@ active_thread() {
get_cpu_time() {
	xtrace_disable

	local interval=$1 cpu_time=${2:-idle} print=${3:-0} interval_count
	shift 3
	local interval=$1 cpu_time=${2:-idle} print=${3:-0} wait=${4:-1} interval_count
	shift 4
	local cpus=("$@") cpu
	local stats stat old_stats avg_load
	local total_sample
@@ -555,7 +555,7 @@ get_cpu_time() {
			old_stats=("${stats[@]}")
			((print == 1)) && print_cpu_time "$cpu"
		done
		sleep 1s
		sleep "${wait}s"
	done

	# We collected % for each time. Now determine the avg % for requested time.
@@ -626,7 +626,7 @@ collect_cpu_idle() {
	printf 'Collecting cpu idle stats (cpus: %s) for %u seconds...\n' \
		"${cpus_to_collect[*]}" "$time"

	get_cpu_time "$time" idle 0 "${cpus_to_collect[@]}"
	get_cpu_time "$time" idle 0 1 "${cpus_to_collect[@]}"

	local user_load
	for cpu in "${cpus_to_collect[@]}"; do