Print the mean of the bugs' own changes as task-bench's All change
CI / tests (pull_request) Successful in 4m28s
CI / tests (pull_request) Successful in 4m28s
This commit is contained in:
+23
-10
@@ -69,10 +69,12 @@ def reads_before(calls: list[ToolCall], bug_file: str) -> int | None:
|
||||
|
||||
def table(results: list[Result], tasks: dict[int, str]) -> list[str]:
|
||||
"""A row per task and side, then one per side over every task, then the head's change against the base. Each figure is the
|
||||
median over the side's runs that have figures, and Reads over those that opened the bug's file."""
|
||||
rows = [row(f"{task}: {tasks[task]}", side, [result for result in results if (result.task, result.side) == (task, side)]) for task in sorted(tasks) for side in SIDES]
|
||||
median over the side's runs that have figures, and Reads over those that opened the bug's file. The change is not the
|
||||
difference of the two All rows: it is the mean of the bugs' own changes."""
|
||||
sides = {(task, side): [result for result in results if (result.task, result.side) == (task, side)] for task in tasks for side in SIDES}
|
||||
rows = [row(f"{task}: {tasks[task]}", side, sides[task, side]) for task in sorted(tasks) for side in SIDES]
|
||||
base, head = ([result for result in results if result.side == side] for side in SIDES)
|
||||
return [*HEADER, *rows, row("All", "base", base), row("All", "head", head), change(base, head)]
|
||||
return [*HEADER, *rows, row("All", "base", base), row("All", "head", head), change(base, head, [(sides[task, "base"], sides[task, "head"]) for task in sorted(tasks)])]
|
||||
|
||||
|
||||
def medians(results: list[Result]) -> list[float | None]:
|
||||
@@ -95,15 +97,26 @@ def row(task: str, side: str, results: list[Result]) -> str:
|
||||
return cells([task, side, passed, *("-" if median is None else number(median) for median in medians(results))])
|
||||
|
||||
|
||||
def change(base: list[Result], head: list[Result]) -> str:
|
||||
"""The head's row less the base's: a count as the difference, and tokens and wall time as that difference's share of the base's."""
|
||||
def change(base: list[Result], head: list[Result], bugs: list[tuple[list[Result], list[Result]]]) -> str:
|
||||
"""The head's change against the base: the pass count as the difference over every run, and each other figure as the mean
|
||||
over the bugs of that bug's own change, which is its head median less its base median. Tokens and wall time show it as a share
|
||||
of the base's median, turns and reads as a count. A bug whose either side lacks the figure, or whose base median is zero where
|
||||
a share is shown, doesn't count towards that figure's mean. The mean of the bugs' changes swings less than the change of
|
||||
the All rows' medians, which lands in whichever bug's runs sit in the middle of the pooled costs."""
|
||||
passed = sum(result.passed for result in head) - sum(result.passed for result in base)
|
||||
pairs = list(zip(medians(base), medians(head)))
|
||||
shares = [None if was is None or now is None or not was else f"{number(round(100 * (now - was) / was), signed=True)} %" for was, now in pairs]
|
||||
counts = [None if was is None or now is None else number(now - was, signed=True) for was, now in pairs]
|
||||
pairs = [list(zip(medians(was), medians(now))) for was, now in bugs]
|
||||
# Turns and reads are small counts, where a share misleads.
|
||||
mixed = [*shares[:4], counts[4], shares[5], counts[6]]
|
||||
return cells(["All", "change", number(passed, signed=True), *(found or "-" for found in mixed)])
|
||||
means = [mean_change(column, share=index not in (4, 6)) for index, column in enumerate(zip(*pairs))] if pairs else [None] * 7
|
||||
return cells(["All", "change", number(passed, signed=True), *(found or "-" for found in means)])
|
||||
|
||||
|
||||
def mean_change(pairs: tuple[tuple[float | None, float | None], ...], share: bool) -> str | None:
|
||||
"""The mean over the (base, head) medians of one figure, one pair per bug; None where no bug has both."""
|
||||
changes = [(now - was) * (100 / was if share else 1) for was, now in pairs if was is not None and now is not None and (was or not share)]
|
||||
if not changes:
|
||||
return None
|
||||
mean = statistics.mean(changes)
|
||||
return f"{number(round(mean), signed=True)} %" if share else number(mean, signed=True)
|
||||
|
||||
|
||||
def number(value: float, signed: bool = False) -> str:
|
||||
|
||||
@@ -36,7 +36,8 @@ example:
|
||||
It prints the base and the head, then a table: a row per bug and side with how many fixes passed and the medians, over the runs
|
||||
that finished, of the input, cache-write, cache-read and output tokens, the turns, the wall time, and the reads and searches before
|
||||
the run first opened the file the bug is in. The median of the reads leaves out a run that never opened that file. Then come a row
|
||||
per side over every bug, and the head's change against the base. The last line names the bench's folder: `task-bench` in the
|
||||
per side over every bug, and the head's change against the base: the pass count's difference, and for each other column the mean over
|
||||
the bugs of that bug's own change, which isn't the difference of the two rows above it. The last line names the bench's folder: `task-bench` in the
|
||||
chunk's review folder.
|
||||
|
||||
That folder holds each run's result and stream, and digest.md, which says why runs failed in a few kilobytes per bug:
|
||||
@@ -46,9 +47,9 @@ That folder holds each run's result and stream, and digest.md, which says why ru
|
||||
passing run with the median tokens. A trace has a line per tool call, such as `Read pick.go:120-180` or `Grep "readName" → 4 hits`, and the first 3 lines of what Haiku wrote
|
||||
between calls.
|
||||
|
||||
Read a change against the noise. With the defaults, a bench of a commit against itself shows, in 19 cases of 20, an All row change
|
||||
under 31% in output tokens, 50% in cache-read tokens and 21% in wall time. The mean of the bugs' own changes, which you work out
|
||||
from the bug rows, stays under 12%, 16% and 10%. On `fejkdata`'s bugs every run passed, so the pass rate's noise is unmeasured.
|
||||
Read a change against the noise. With the defaults, a bench of a commit against itself shows, in 19 cases of 20, a change under
|
||||
12% in output tokens, 16% in cache-read tokens and 10% in wall time. On `fejkdata`'s bugs every run passed, so the pass rate's noise
|
||||
is unmeasured.
|
||||
`docs/decisions.md` → `task-bench: a bench takes` has the figures.
|
||||
|
||||
`task-bench gather`, run in the same checkout, turns the digest into plan items. It starts a claude on the project's rung, the
|
||||
|
||||
@@ -102,6 +102,25 @@ class TableTest(unittest.TestCase):
|
||||
results = [run(1, "base", 1, True, input_=0, turns=10, seconds=60, reads=0), run(1, "head", 1, False, input_=50, turns=12, seconds=120, reads=2)]
|
||||
self.assertEqual(table(results, {1: "calc.go:4:7 ARITHMETIC_BASE"})[-1], "| All | change | -1 | - | 0 % | 0 % | 0 % | +2 | +100 % | +2 |")
|
||||
|
||||
def test_the_change_is_the_mean_of_the_bugs_own_changes_not_the_change_of_the_pooled_medians(self):
|
||||
results = [
|
||||
run(1, "base", 1, True, input_=100, turns=10, seconds=60, reads=3), run(1, "head", 1, True, input_=200, turns=14, seconds=90, reads=5),
|
||||
run(2, "base", 1, True, input_=1000, turns=20, seconds=60, reads=7), run(2, "head", 1, True, input_=1000, turns=20, seconds=60, reads=7),
|
||||
]
|
||||
rows = table(results, {1: "calc.go:4:7 ARITHMETIC_BASE", 2: "pick.go:9:3 ARITHMETIC_BASE"})
|
||||
self.assertEqual(rows[-3:], [
|
||||
"| All | base | 2/2 | 550 | 1000 | 5000 | 400 | 15 | 60 | 5 |",
|
||||
"| All | head | 2/2 | 600 | 1000 | 5000 | 400 | 17 | 75 | 6 |",
|
||||
"| All | change | 0 | +50 % | 0 % | 0 % | 0 % | +2 | +25 % | +1 |",
|
||||
])
|
||||
|
||||
def test_a_bug_whose_base_measured_zero_is_left_out_of_the_mean_share(self):
|
||||
results = [
|
||||
run(1, "base", 1, True, input_=0), run(1, "head", 1, True, input_=50),
|
||||
run(2, "base", 1, True, input_=100), run(2, "head", 1, True, input_=150),
|
||||
]
|
||||
self.assertEqual(table(results, {1: "a.go:1:1 ARITHMETIC_BASE", 2: "b.go:1:1 ARITHMETIC_BASE"})[-1].split(" | ")[3], "+50 %")
|
||||
|
||||
def test_a_run_without_figures_counts_as_not_passed_and_a_side_without_any_shows_a_dash(self):
|
||||
results = [Result(1, "base", 1, False, None), run(1, "head", 1, True)]
|
||||
self.assertEqual(table(results, {1: "calc.go:4:7 ARITHMETIC_BASE"})[2:], [
|
||||
|
||||
Reference in New Issue
Block a user