From 667e6433a6724d314b691a3687eac3e130c764b5 Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Sat, 21 Dec 2024 11:30:36 +0400 Subject: [PATCH] refactor: move hyperfine call into fn, cleanup code Also tried +short and -Q options for dig and drill, but it only increased time. Anyway, now it's more convenient to append options. --- main.sh | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/main.sh b/main.sh index ff0aaba..8e50662 100755 --- a/main.sh +++ b/main.sh @@ -57,43 +57,35 @@ echo echo '==> Starting Unbound' unbound -c ./unbound.conf -dp 2>unbound.log & unbound_pid=$! -sleep 4 +sleep 2 +run_bench () { + hyperfine -N -w 30 \ + "$exe_dig -p 2253 $1 $2 @127.0.0.1" \ + "$exe_drill -p 2253 $1 $2 @127.0.0.1" \ + "$exe_hr -n 127.0.0.1:2253 -t $1 $2" +} + echo echo '==> Benchmarks for A domain.tld.' -hyperfine -N -w 30 \ - "$exe_dig -p 2253 domain.tld @127.0.0.1" \ - "$exe_drill -p 2253 domain.tld @127.0.0.1" \ - "$exe_hr -n 127.0.0.1:2253 domain.tld" +run_bench A domain.tld echo echo '==> Benchmarks for AAAA domain.tld.' -hyperfine -N -w 30 \ - "$exe_dig -p 2253 aaaa domain.tld @127.0.0.1" \ - "$exe_drill -p 2253 aaaa domain.tld @127.0.0.1" \ - "$exe_hr -n 127.0.0.1:2253 -t AAAA domain.tld" +run_bench AAAA domain.tld echo echo '==> Benchmarks for MX domain.tld.' -hyperfine -N -w 30 \ - "$exe_dig -p 2253 mx domain.tld @127.0.0.1" \ - "$exe_drill -p 2253 mx domain.tld @127.0.0.1" \ - "$exe_hr -n 127.0.0.1:2253 -t MX domain.tld" +run_bench MX domain.tld echo echo '==> Benchmarks for CNAME mail.domain.tld.' -hyperfine -N -w 30 \ - "$exe_dig -p 2253 mail.domain.tld @127.0.0.1" \ - "$exe_drill -p 2253 mail.domain.tld @127.0.0.1" \ - "$exe_hr -n 127.0.0.1:2253 mail.domain.tld" +run_bench A mail.domain.tld echo echo '==> Benchmarks for TXT txt.domain.tld.' -hyperfine -N -w 30 \ - "$exe_dig -p 2253 txt txt.domain.tld @127.0.0.1" \ - "$exe_drill -p 2253 txt txt.domain.tld @127.0.0.1" \ - "$exe_hr -n 127.0.0.1:2253 -t TXT txt.domain.tld" +run_bench TXT txt.domain.tld echo