fix(scripts): Fix the output and recording of data
This commit is contained in:
+1
-1
@@ -293,7 +293,7 @@ func createClient(scheme, host, port, path string, opts Options) (DNSClient, err
|
|||||||
// Janky solution but whatever
|
// Janky solution but whatever
|
||||||
// Here we rejoin them as the client wants them together
|
// Here we rejoin them as the client wants them together
|
||||||
// The host is not really a host but whatever
|
// The host is not really a host but whatever
|
||||||
ServerStamp: fmt.Sprintf("%v://%v",scheme,host),
|
ServerStamp: fmt.Sprintf("%v://%v", scheme, host),
|
||||||
DNSSEC: opts.DNSSEC,
|
DNSSEC: opts.DNSSEC,
|
||||||
}
|
}
|
||||||
logger.Debug("Creating DNSCrypt client with stamp")
|
logger.Debug("Creating DNSCrypt client with stamp")
|
||||||
|
|||||||
+13
-13
@@ -40,18 +40,18 @@ func GenerateOutputPaths(outputDir, upstream string, dnssec, authDNSSEC, keepAli
|
|||||||
func cleanServerName(server string) string {
|
func cleanServerName(server string) string {
|
||||||
// Map common servers to readable names
|
// Map common servers to readable names
|
||||||
serverMap := map[string]string{
|
serverMap := map[string]string{
|
||||||
"1.1.1.1": "cloudflare",
|
"1.1.1.1": "cloudflare",
|
||||||
"1.0.0.1": "cloudflare",
|
"1.0.0.1": "cloudflare",
|
||||||
"cloudflare-dns.com": "cloudflare",
|
"cloudflare-dns.com": "cloudflare",
|
||||||
"one.one.one.one": "cloudflare",
|
"one.one.one.one": "cloudflare",
|
||||||
"8.8.8.8": "google",
|
"8.8.8.8": "google",
|
||||||
"8.8.4.4": "google",
|
"8.8.4.4": "google",
|
||||||
"dns.google": "google",
|
"dns.google": "google",
|
||||||
"dns.google.com": "google",
|
"dns.google.com": "google",
|
||||||
"9.9.9.9": "quad9",
|
"9.9.9.9": "quad9",
|
||||||
"149.112.112.112": "quad9",
|
"149.112.112.112": "quad9",
|
||||||
"dns.quad9.net": "quad9",
|
"dns.quad9.net": "quad9",
|
||||||
"dns10.quad9.net": "quad9",
|
"dns10.quad9.net": "quad9",
|
||||||
"AQMAAAAAAAAAFDE0OS4xMTIuMTEyLjExMjo4NDQzIGfIR7jIdYzRICRVQ751Z0bfNN8dhMALjEcDaN-CHYY-GTIuZG5zY3J5cHQtY2VydC5xdWFkOS5uZXQ": "quad9",
|
"AQMAAAAAAAAAFDE0OS4xMTIuMTEyLjExMjo4NDQzIGfIR7jIdYzRICRVQ751Z0bfNN8dhMALjEcDaN-CHYY-GTIuZG5zY3J5cHQtY2VydC5xdWFkOS5uZXQ": "quad9",
|
||||||
"208.67.222.222": "opendns",
|
"208.67.222.222": "opendns",
|
||||||
"208.67.220.220": "opendns",
|
"208.67.220.220": "opendns",
|
||||||
@@ -60,7 +60,7 @@ func cleanServerName(server string) string {
|
|||||||
"94.140.15.15": "adguard",
|
"94.140.15.15": "adguard",
|
||||||
"dns.adguard.com": "adguard",
|
"dns.adguard.com": "adguard",
|
||||||
"dns.adguard-dns.com": "adguard",
|
"dns.adguard-dns.com": "adguard",
|
||||||
"AQMAAAAAAAAAETk0LjE0MC4xNS4xNTo1NDQzINErR_JS3PLCu_iZEIbq95zkSV2LFsigxDIuUso_OQhzIjIuZG5zY3J5cHQuZGVmYXVsdC5uczEuYWRndWFyZC5jb20": "adguard",
|
"AQMAAAAAAAAAETk0LjE0MC4xNC4xNDo1NDQzINErR_JS3PLCu_iZEIbq95zkSV2LFsigxDIuUso_OQhzIjIuZG5zY3J5cHQuZGVmYXVsdC5uczEuYWRndWFyZC5jb20": "adguard",
|
||||||
}
|
}
|
||||||
|
|
||||||
serverName := ""
|
serverName := ""
|
||||||
|
|||||||
+18
-14
@@ -137,11 +137,20 @@ run_with_perf() {
|
|||||||
if [[ -n "$suffix" ]]; then
|
if [[ -n "$suffix" ]]; then
|
||||||
base_name="${name}-${suffix}"
|
base_name="${name}-${suffix}"
|
||||||
fi
|
fi
|
||||||
local cpu_csv_file="$OUTPUT_DIR/${name%%-*}/${base_name}.cpu.csv" # e.g., results/cloudflare/dot-trust-persist.cpu.csv
|
local provider="${name%%-*}"
|
||||||
|
local protocol="${name#*-}"
|
||||||
|
local base_name="${protocol}"
|
||||||
|
if [[ -n "$suffix" ]]; then
|
||||||
|
base_name="${protocol}-${suffix}"
|
||||||
|
fi
|
||||||
|
local cpu_csv_file="$OUTPUT_DIR/${provider}/${base_name}.cpu.csv"
|
||||||
|
|
||||||
|
# Create directory if needed
|
||||||
|
mkdir -p "$(dirname "$cpu_csv_file")"
|
||||||
|
|
||||||
# Write header if needed
|
# Write header if needed
|
||||||
if [[ ! -f "$cpu_csv_file" ]]; then
|
if [[ ! -f "$cpu_csv_file" ]]; then
|
||||||
echo "timestamp,wall_time_seconds,instructions,cycles,peak_rss_kb" > "$cpu_csv_file"
|
echo "timestamp,wall_time_seconds,instructions,cycles" > "$cpu_csv_file"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Build command arguments
|
# Build command arguments
|
||||||
@@ -156,7 +165,7 @@ run_with_perf() {
|
|||||||
if [[ "$dnssec" == "true" ]]; then
|
if [[ "$dnssec" == "true" ]]; then
|
||||||
cmd_args+=(--dnssec)
|
cmd_args+=(--dnssec)
|
||||||
if [[ "$auth" == "true" ]]; then
|
if [[ "$auth" == "true" ]]; then
|
||||||
cmd_args+=(--auth-dnssec)
|
cmd_args+=(--authoritative-dnssec)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -164,31 +173,26 @@ run_with_perf() {
|
|||||||
cmd_args+=(--keep-alive)
|
cmd_args+=(--keep-alive)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create temp files for perf and time output
|
# Create temp file for perf
|
||||||
local perf_tmp=$(mktemp)
|
local perf_tmp=$(mktemp)
|
||||||
local time_tmp=$(mktemp)
|
|
||||||
|
|
||||||
# Run with perf stat and /usr/bin/time
|
# Run with perf stat
|
||||||
local timestamp=$(date -Iseconds)
|
local timestamp=$(date -Iseconds)
|
||||||
|
|
||||||
sudo perf stat -e instructions,cycles \
|
perf stat -e instructions,cycles \
|
||||||
-o "$perf_tmp" \
|
-o "$perf_tmp" \
|
||||||
/usr/bin/time -v \
|
"$TOOL_PATH" run "${cmd_args[@]}" || true
|
||||||
"$TOOL_PATH" run "${cmd_args[@]}" 2>"$time_tmp" || true
|
|
||||||
|
|
||||||
# Parse perf output
|
# Parse perf output
|
||||||
local instructions=$(grep -oP '\d[\d,]*(?=\s+instructions)' "$perf_tmp" 2>/dev/null | tr -d ',' || echo "0")
|
local instructions=$(grep -oP '\d[\d,]*(?=\s+instructions)' "$perf_tmp" 2>/dev/null | tr -d ',' || echo "0")
|
||||||
local cycles=$(grep -oP '\d[\d,]*(?=\s+cycles)' "$perf_tmp" 2>/dev/null | tr -d ',' || echo "0")
|
local cycles=$(grep -oP '\d[\d,]*(?=\s+cycles)' "$perf_tmp" 2>/dev/null | tr -d ',' || echo "0")
|
||||||
local wall_time=$(grep -oP '\d+\.\d+(?= seconds time elapsed)' "$perf_tmp" 2>/dev/null || echo "0")
|
local wall_time=$(grep -oP '\d+\.\d+(?= seconds time elapsed)' "$perf_tmp" 2>/dev/null || echo "0")
|
||||||
|
|
||||||
# Parse /usr/bin/time output for peak RSS
|
|
||||||
local peak_rss=$(grep "Maximum resident set size" "$time_tmp" 2>/dev/null | grep -oP '\d+' || echo "0")
|
|
||||||
|
|
||||||
# Append to CPU CSV
|
# Append to CPU CSV
|
||||||
echo "${timestamp},${wall_time},${instructions},${cycles},${peak_rss}" >> "$cpu_csv_file"
|
echo "${timestamp},${wall_time},${instructions},${cycles}" >> "$cpu_csv_file"
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
rm -f "$perf_tmp" "$time_tmp"
|
rm -f "$perf_tmp"
|
||||||
|
|
||||||
echo " -> CPU metrics saved to ${base_name}.cpu.csv"
|
echo " -> CPU metrics saved to ${base_name}.cpu.csv"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user