Skip to content

simplify: reduce duplication in declarative benchmark helpers#900

Merged
rspurgeon merged 3 commits intomainfrom
copilot/simplify-code-in-declarative-files
Apr 26, 2026
Merged

simplify: reduce duplication in declarative benchmark helpers#900
rspurgeon merged 3 commits intomainfrom
copilot/simplify-code-in-declarative-files

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 25, 2026

Five redundant patterns in test/benchmarks/declarative/ identified and eliminated.

Changes

  • caseTokenMatches — return boolean expression directly; drop wrapping if/return true/return false
  • boolEnv — merge case "": into default (identical bodies); inline value variable
  • medianInt + medianInt64median[T int | int64] — unified with Go generics; call sites infer type
  • percentDelta + percentDelta64percentDelta[T int | int64] — same pattern; percentDelta64(...) call site updated to percentDelta(...)
  • maxFloat — replace manual accumulator loop with slices.Max; empty-slice guard retained (panics on empty input)

Copilot AI linked an issue Apr 25, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits April 25, 2026 22:25
- caseTokenMatches: return bool expression directly
- boolEnv: collapse empty-string case into default, inline value var
- medianInt/medianInt64: unify into generic median[T int | int64]
- percentDelta/percentDelta64: unify into generic percentDelta[T int | int64]
- maxFloat: replace manual loop with slices.Max

Agent-Logs-Url: https://github.com/Kong/kongctl/sessions/ff84046f-b15a-41bd-9242-102e0c71741a

Co-authored-by: rspurgeon <10521262+rspurgeon@users.noreply.github.com>
Copilot AI changed the title [WIP] Simplify code in benchmarks for clarity and maintainability simplify: reduce duplication in declarative benchmark helpers Apr 25, 2026
Copilot AI requested a review from rspurgeon April 25, 2026 22:28
@rspurgeon rspurgeon marked this pull request as ready for review April 26, 2026 15:09
@rspurgeon rspurgeon requested review from a team as code owners April 26, 2026 15:09
Copilot AI review requested due to automatic review settings April 26, 2026 15:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the declarative benchmark helpers under test/benchmarks/declarative/ to remove small pockets of duplicated logic and simplify a few helper functions, improving readability and keeping behavior consistent.

Changes:

  • Simplifies boolean helpers (caseTokenMatches, boolEnv) by returning expressions directly / removing redundant switch cases.
  • Unifies duplicated median and percentDelta helpers via Go generics (int | int64) and updates call sites.
  • Replaces a manual max loop with slices.Max and ignores a Bubbletea test debug log file in .gitignore.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
test/benchmarks/declarative/main.go Simplifies selector/env helpers and consolidates median/percentDelta logic using generics.
test/benchmarks/declarative/report.go Simplifies maxFloat implementation by using slices.Max while preserving the empty-input guard.
.gitignore Adds tea_debug.log to avoid committing Bubbletea debug logs generated during tests.

@rspurgeon rspurgeon merged commit 45563b8 into main Apr 26, 2026
12 checks passed
@rspurgeon rspurgeon deleted the copilot/simplify-code-in-declarative-files branch April 26, 2026 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[simplifier] Code Simplification - 2026-04-25

3 participants