Repository navigation
Let tally accept replace a preset complexity class that the growth no longer fits - #8
Merged
Merged
Conversation
… longer fits A benchmark compared by its growth had nothing for tally accept to write, so a slower case meant editing the attribute by hand and guessing the class. Accept now fits the measured instructions of a method's data sets against the presets and writes the lowest one they grow within, as tally run compares them: up when they grew more than the class allows, such as #[Constant] to #[Logarithmic], down when a lower preset bounds them too, such as #[Linear] to #[Logarithmic]. The size argument stays as written, and the import of the replaced class goes when nothing else uses it. Classes are compared at the measured sizes only, so #[Exponential] comes before a preset that allows more growth at the largest data set; otherwise any growth would fit some high-degree polynomial. A #[Complexity] with its own formula is left alone, and a method no preset bounds is reported. Amp-Thread-ID: https://ampcode.com/threads/T-01a1d9f0-e845-746f-86dc-7977af8ab66d
ondrejmirtes
force-pushed
the
accept-complexity-presets
branch
from
November 14, 2026 21:13
b9c953a to
3c0a908
Compare
…replacement The Benchmarks job measured index() 44 % slower and planning 2.5 % slower with 68 % more memory: indexing counted every name of the file and read the size argument of every attribute, and plan() built a closure per case. Now the index only records where a method's other attributes are, accept tokenizes the one complexity attribute it replaces and looks for other uses of its import then, and complexity changes get a loop of their own. Locally under CodSpeed the benchmarks are within 0.6 % of instructions and 1.1 % of memory of 1.x. Amp-Thread-ID: https://ampcode.com/threads/T-01a1d9f0-e845-746f-86dc-7977af8ab66d
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A benchmark compared by its growth had nothing for
tally acceptto write: a slower case meant editing the attribute by hand. Accept now fits the measured instructions of a method's data sets against the presets and writes the lowest one they grow within, astally runcompares them.#[Constant]to#[Logarithmic], down when a lower preset bounds them too, such as#[Linear]to#[Logarithmic](listed as faster).CodeEdits in the file'sAttributeIndex, like the expectations since 5ed6578, so a file with both is rewritten in one pass. The new import takes the place of the removed one when it sorts there.#[Exponential]comes before a preset that allows more growth at the largest data set. Otherwise any growth would fit some high-degree polynomial.#[Polynomial(degree: 1)]stays).#[Complexity]with its own formula is left alone.Cannot accept App\FooBench::benchFoo: no preset complexity class bounds how its instructions grow, write a #[Complexity] that does.The other changes are still written, and accept exits with 2.PresetFitTestcovers each neighbouring pair of presets, up and down.CompareAndAcceptCommandTestruns accept end to end on a fixture.Checks: lint, cs, PHPStan, tests, 100 % coverage, and Infection on the changed files at 100 % MSI pass locally.
make benchwas not run;ExpectationChanges::plan()changed, so the Benchmarks job may report new numbers.Known limitation: accept with
--filterfits the class to the selected data sets only.