|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Copyright 2016 The Cockroach Authors. |
| 4 | +# |
| 5 | +# Use of this software is governed by the CockroachDB Software License |
| 6 | +# included in the /LICENSE file. |
| 7 | + |
| 8 | +# Root directory to start searching |
| 9 | +ROOT_DIR=${1:-.} # defaults to current directory if not specified |
| 10 | + |
| 11 | +# Function to extract and format benchmark data |
| 12 | +extract_benchmark_data() { |
| 13 | + local file_path="$1" |
| 14 | + local bench_prefix |
| 15 | + |
| 16 | + # Extract the benchmark path, trimming to tpcc-nowait/.../cpu=16 (any strategy in place of "literal"/"optimized") |
| 17 | + bench_prefix=$(echo "$file_path" | sed -E 's|.*/(tpcc-nowait/[^/]+/w=[^/]+/nodes=[^/]+/cpu=[^/]+)/run_[^/]+/.*|\1|') |
| 18 | + |
| 19 | + # Process only after first "total" header and stop if "tpmC" is seen |
| 20 | + awk -v prefix="$bench_prefix" ' |
| 21 | + /tpmC/ { exit } # stop processing after tpmC |
| 22 | + /total/ { found_total = 1 } |
| 23 | + !found_total { next } |
| 24 | +
|
| 25 | + /^_elapsed___errors/ { |
| 26 | + header = 1 |
| 27 | + next |
| 28 | + } |
| 29 | + header == 1 && /^[[:space:]]*[0-9]+\.[0-9]+s/ { |
| 30 | + # Capture values and label (last column) |
| 31 | + elapsed = $1 |
| 32 | + ops_total = $3 |
| 33 | + ops_sec = $4 |
| 34 | + avg_ms = $5 |
| 35 | + p50 = $6 |
| 36 | + p95 = $7 |
| 37 | + p99 = $8 |
| 38 | + pmax = $9 |
| 39 | + label = $10 |
| 40 | +
|
| 41 | + # Remove units and convert label to lowercase |
| 42 | + gsub(/s$/, "", elapsed) |
| 43 | + label_lc = tolower(label) |
| 44 | + if (label_lc == "") label_lc = "total" |
| 45 | +
|
| 46 | + printf "BenchmarkTPCC/%s/%-12s %10s %8s ops/sec %8s ms/avg %8s ms/p50 %8s ms/p95 %8s ms/p99 %8s ms/max\n", \ |
| 47 | + prefix, label_lc, ops_total, ops_sec, avg_ms, p50, p95, p99, pmax |
| 48 | + } |
| 49 | + ' "$file_path" |
| 50 | +} |
| 51 | + |
| 52 | +export -f extract_benchmark_data |
| 53 | + |
| 54 | +# Find all matching files and process them |
| 55 | +find "$ROOT_DIR" -type f -path "*/tpcc-nowait/*/w=*/nodes=*/cpu=*/run_*/"*"_cockroach-workload-r.log" \ |
| 56 | + -exec bash -c 'extract_benchmark_data "$0"' {} \; |
0 commit comments