From 2cb3e42b7ea9ba6b169d02827475a6a19fd35b3b Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Wed, 26 Jul 2023 01:00:48 +0200 Subject: use tabs consistently --- .editorconfig | 19 ++++--- ci.sh | 26 +++++----- scripts/flamegraph.sh | 140 +++++++++++++++++++++++++------------------------- scripts/valgrind.sh | 18 +++---- 4 files changed, 101 insertions(+), 102 deletions(-) diff --git a/.editorconfig b/.editorconfig index 4623061..83044fd 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,19 +1,18 @@ root = true [*] -indent_style = space -indent_size = 4 -insert_final_newline = true - -[Makefile] -indent_style = tab - -[*.{c,h}] indent_style = tab indent_size = 8 +insert_final_newline = true -[*.sql] -indent_style = tab +[CMakeLists.txt] +indent_style = space +indent_size = 4 + +[*.py] +indent_style = space +indent_size = 4 [*.yml] +indent_style = space indent_size = 2 diff --git a/ci.sh b/ci.sh index dd45b89..82bf069 100755 --- a/ci.sh +++ b/ci.sh @@ -4,28 +4,28 @@ set -o errexit -o nounset -o pipefail shopt -s inherit_errexit lastpipe test_build() { - docker-compose build --progress plain --pull "$@" + docker-compose build --progress plain --pull "$@" } test_build_clang() { - echo ---------------------------------------------------------------------- - echo Building w/ clang - echo ---------------------------------------------------------------------- - echo - test_build --build-arg COMPILER=clang + echo ---------------------------------------------------------------------- + echo Building w/ clang + echo ---------------------------------------------------------------------- + echo + test_build --build-arg COMPILER=clang } test_build_gcc() { - echo ---------------------------------------------------------------------- - echo Building w/ gcc - echo ---------------------------------------------------------------------- - echo - test_build --build-arg COMPILER=gcc + echo ---------------------------------------------------------------------- + echo Building w/ gcc + echo ---------------------------------------------------------------------- + echo + test_build --build-arg COMPILER=gcc } main() { - test_build_gcc - test_build_clang + test_build_gcc + test_build_clang } main diff --git a/scripts/flamegraph.sh b/scripts/flamegraph.sh index b3be88b..032b86e 100755 --- a/scripts/flamegraph.sh +++ b/scripts/flamegraph.sh @@ -15,99 +15,99 @@ script_name="$( basename -- "${BASH_SOURCE[0]}" )" readonly script_name script_usage() { - local msg - for msg; do - echo "$script_name: $msg" - done + local msg + for msg; do + echo "$script_name: $msg" + done - echo "usage: $script_name OUTPUT_PATH PID [PID...]" + echo "usage: $script_name OUTPUT_PATH PID [PID...]" } join_pids() { - local result='' - while [ "$#" -gt 0 ]; do - if [ -n "$result" ]; then - result="$result," - fi - result="$result$1" - shift - done - echo "$result" + local result='' + while [ "$#" -gt 0 ]; do + if [ -n "$result" ]; then + result="$result," + fi + result="$result$1" + shift + done + echo "$result" } output_dir='' cleanup() { - if [ -n "$output_dir" ]; then - echo "Removing temporary directory: $output_dir" - rm -rf -- "$output_dir" - fi + if [ -n "$output_dir" ]; then + echo "Removing temporary directory: $output_dir" + rm -rf -- "$output_dir" + fi } make_graph() { - wait "$record_pid" || true - perf script -i "$output_dir/perf.data" > "$output_dir/perf.out" - stackcollapse-perf.pl "$output_dir/perf.out" > "$output_dir/perf.folded" - flamegraph.pl --width 1400 --color mem "$output_dir/perf.folded" > "$output_path" + wait "$record_pid" || true + perf script -i "$output_dir/perf.data" > "$output_dir/perf.out" + stackcollapse-perf.pl "$output_dir/perf.out" > "$output_dir/perf.folded" + flamegraph.pl --width 1400 --color mem "$output_dir/perf.folded" > "$output_path" } record_pid='' stop_record() { - echo "Stopping 'perf record' process $record_pid" - kill -SIGINT "$record_pid" - make_graph + echo "Stopping 'perf record' process $record_pid" + kill -SIGINT "$record_pid" + make_graph } check_tools() { - local tool - for tool in perf stackcollapse-perf.pl flamegraph.pl; do - if ! command -v "$tool" &> /dev/null; then - echo "$script_name: $tool is missing" >&2 - exit 1 - fi - done + local tool + for tool in perf stackcollapse-perf.pl flamegraph.pl; do + if ! command -v "$tool" &> /dev/null; then + echo "$script_name: $tool is missing" >&2 + exit 1 + fi + done } main() { - trap cleanup EXIT - check_tools - - if [ "$#" -lt 1 ]; then - script_usage "output path is required" >&2 - exit 1 - fi - local output_path="$1" - output_path="$( realpath -- "$output_path" )" - shift - - if [ "$#" -lt 1 ]; then - script_usage "at least one process ID is required" >&2 - exit 1 - fi - local pids - pids="$( join_pids "$@" )" - shift - - echo "Output path: $output_path" - echo "PIDs: $pids" - - output_dir="$( dirname -- "$output_path" )" - output_dir="$( mktemp -d --tmpdir="$output_dir" )" - readonly output_dir - - perf record \ - -o "$output_dir/perf.data" \ - --freq=99 \ - --call-graph dwarf,65528 \ - --pid="$pids" \ - --no-inherit & - - record_pid="$!" - echo "Started 'perf record' process $record_pid" - trap stop_record SIGINT SIGTERM - - make_graph + trap cleanup EXIT + check_tools + + if [ "$#" -lt 1 ]; then + script_usage "output path is required" >&2 + exit 1 + fi + local output_path="$1" + output_path="$( realpath -- "$output_path" )" + shift + + if [ "$#" -lt 1 ]; then + script_usage "at least one process ID is required" >&2 + exit 1 + fi + local pids + pids="$( join_pids "$@" )" + shift + + echo "Output path: $output_path" + echo "PIDs: $pids" + + output_dir="$( dirname -- "$output_path" )" + output_dir="$( mktemp -d --tmpdir="$output_dir" )" + readonly output_dir + + perf record \ + -o "$output_dir/perf.data" \ + --freq=99 \ + --call-graph dwarf,65528 \ + --pid="$pids" \ + --no-inherit & + + record_pid="$!" + echo "Started 'perf record' process $record_pid" + trap stop_record SIGINT SIGTERM + + make_graph } main "$@" diff --git a/scripts/valgrind.sh b/scripts/valgrind.sh index db05a1d..c59664d 100755 --- a/scripts/valgrind.sh +++ b/scripts/valgrind.sh @@ -4,15 +4,15 @@ set -o errexit -o nounset -o pipefail shopt -s inherit_errexit lastpipe if ! command -v valgrind &> /dev/null; then - echo 'Please make sure valgrind is available.' >&2 - exit 1 + echo 'Please make sure valgrind is available.' >&2 + exit 1 fi exec valgrind -q \ - --error-exitcode=10 \ - --leak-check=full \ - --show-leak-kinds=all \ - --track-origins=yes \ - --track-fds=yes \ - --trace-children=yes \ - "$@" + --error-exitcode=10 \ + --leak-check=full \ + --show-leak-kinds=all \ + --track-origins=yes \ + --track-fds=yes \ + --trace-children=yes \ + "$@" -- cgit v1.2.3