Skip to content

Commit 9fc3c93

Browse files
committed
looking good
1 parent c2cf181 commit 9fc3c93

1 file changed

Lines changed: 39 additions & 12 deletions

File tree

cache/__tests__/cache-metrics-worst-case.sh

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,12 +1586,21 @@ test_unset_endpoint_full() {
15861586
echo "" >&2
15871587
[ $success -eq 0 ] && return
15881588
ENDPOINT_WARM_TIMES["unset"]=$((total / success))
1589-
local overhead=$((ENDPOINT_WARM_TIMES["unset"] - ENDPOINT_COLD_TIMES["unset"]))
1590-
local empty=${ENDPOINT_COLD_TIMES["unset"]}
1589+
local empty=${ENDPOINT_COLD_TIMES["unset"]:-0}
15911590
local full=${ENDPOINT_WARM_TIMES["unset"]}
1592-
local overhead_pct=$((overhead * 100 / empty))
15931591

1594-
log_overhead $overhead "Overhead: ${overhead}ms (${overhead_pct}%) [Empty: ${empty}ms → Full: ${full}ms]"
1592+
if [ "$empty" -eq 0 ] || [ -z "$empty" ]; then
1593+
log_warning "Cannot calculate overhead - baseline test had no successful operations"
1594+
else
1595+
local overhead=$((full - empty))
1596+
local overhead_pct=$((overhead * 100 / empty))
1597+
1598+
if [ $overhead -lt 0 ]; then
1599+
log_overhead 0 "Overhead: 0ms (0%) [Empty: ${empty}ms → Full: ${full}ms] (negligible - within statistical variance)"
1600+
else
1601+
log_overhead $overhead "Overhead: ${overhead}ms (${overhead_pct}%) [Empty: ${empty}ms → Full: ${full}ms]"
1602+
fi
1603+
fi
15951604
}
15961605

15971606
test_overwrite_endpoint_empty() {
@@ -1643,12 +1652,21 @@ test_overwrite_endpoint_full() {
16431652
echo "" >&2
16441653
[ $success -eq 0 ] && return
16451654
ENDPOINT_WARM_TIMES["overwrite"]=$((total / success))
1646-
local overhead=$((ENDPOINT_WARM_TIMES["overwrite"] - ENDPOINT_COLD_TIMES["overwrite"]))
1647-
local empty=${ENDPOINT_COLD_TIMES["overwrite"]}
1655+
local empty=${ENDPOINT_COLD_TIMES["overwrite"]:-0}
16481656
local full=${ENDPOINT_WARM_TIMES["overwrite"]}
1649-
local overhead_pct=$((overhead * 100 / empty))
16501657

1651-
log_overhead $overhead "Overhead: ${overhead}ms (${overhead_pct}%) [Empty: ${empty}ms → Full: ${full}ms]"
1658+
if [ "$empty" -eq 0 ] || [ -z "$empty" ]; then
1659+
log_warning "Cannot calculate overhead - baseline test had no successful operations"
1660+
else
1661+
local overhead=$((full - empty))
1662+
local overhead_pct=$((overhead * 100 / empty))
1663+
1664+
if [ $overhead -lt 0 ]; then
1665+
log_overhead 0 "Overhead: 0ms (0%) [Empty: ${empty}ms → Full: ${full}ms] (negligible - within statistical variance)"
1666+
else
1667+
log_overhead $overhead "Overhead: ${overhead}ms (${overhead_pct}%) [Empty: ${empty}ms → Full: ${full}ms]"
1668+
fi
1669+
fi
16521670
}
16531671

16541672
test_delete_endpoint_empty() {
@@ -1720,12 +1738,21 @@ test_delete_endpoint_full() {
17201738
echo "" >&2
17211739
[ $success -eq 0 ] && return
17221740
ENDPOINT_WARM_TIMES["delete"]=$((total / success))
1723-
local overhead=$((ENDPOINT_WARM_TIMES["delete"] - ENDPOINT_COLD_TIMES["delete"]))
1724-
local empty=${ENDPOINT_COLD_TIMES["delete"]}
1741+
local empty=${ENDPOINT_COLD_TIMES["delete"]:-0}
17251742
local full=${ENDPOINT_WARM_TIMES["delete"]}
1726-
local overhead_pct=$((overhead * 100 / empty))
17271743

1728-
log_overhead $overhead "Overhead: ${overhead}ms (${overhead_pct}%) [Empty: ${empty}ms → Full: ${full}ms] (deleted: $success)"
1744+
if [ "$empty" -eq 0 ] || [ -z "$empty" ]; then
1745+
log_warning "Cannot calculate overhead - baseline test had no successful operations"
1746+
else
1747+
local overhead=$((full - empty))
1748+
local overhead_pct=$((overhead * 100 / empty))
1749+
1750+
if [ $overhead -lt 0 ]; then
1751+
log_overhead 0 "Overhead: 0ms (0%) [Empty: ${empty}ms → Full: ${full}ms] (negligible - within statistical variance) (deleted: $success)"
1752+
else
1753+
log_overhead $overhead "Overhead: ${overhead}ms (${overhead_pct}%) [Empty: ${empty}ms → Full: ${full}ms] (deleted: $success)"
1754+
fi
1755+
fi
17291756
}
17301757

17311758
################################################################################

0 commit comments

Comments
 (0)