Skip to content

fix(uri): make benchmark source file detection language-agnostic - #16

Draft
not-matthias wants to merge 1 commit into
mainfrom
cod-3563-fix-source-file-detection-in-codspeed-jvm-for-kotlinscala
Draft

not-matthias wants to merge 1 commit into
mainfrom
cod-3563-fix-source-file-detection-in-codspeed-jvm-for-kotlinscala

Conversation

@not-matthias

Copy link
Copy Markdown
Member

Summary

BenchmarkUri.resolveSourceFile hardcoded a .java suffix when locating a benchmark's source file for the CodSpeed URI ({file_path}::{classQName}::{method}), so Kotlin/Scala benchmarks silently got a non-existent Foo.java path.

Resolution order is now:

  1. <pkg>/<SourceFile> where SourceFile is read from the compiled class file's SourceFile attribute (ClassFileSourceName). This covers Kotlin, where the file name often differs from the class name (e.g. benchmarks.kt).
  2. <pkg>/<SimpleName>.{java,kt,scala,groovy} found on disk.
  3. Package-derived fallback string: <pkg>/<SourceFile> if known, else <pkg>/<SimpleName>.java (unchanged from before).

findFile was refactored into a single predicate-based walker; skip rules (hidden dirs, build, target, node_modules) are unchanged.

Testing

  • BenchmarkUriTest: 17/17 (10 new: kt/scala by extension, Kotlin file name differing from class name, skipped build/, inner class, both fallbacks, real SourceFile read, end-to-end path for the test class itself).
  • Smoke: compiled class KotlinBench in benchmarks.kt with kotlinc 2.4 and ran the cached public path: sourcefile=benchmarks.kt, resolved=src/com/example/benchmarks.kt.

Fixes COD-3563

Resolve the source path from the class file's SourceFile attribute
first, then fall back to searching known source extensions
(java, kt, scala, groovy) instead of hardcoding .java. Kotlin and
Scala benchmarks now get the correct file_path in their CodSpeed URI.
@codspeed

codspeed Bot commented Sep 18, 2026

Copy link
Copy Markdown

Hooray! CodSpeed harness just leveled up!

The base and head of this comparison were measured with different runner settings, so their benchmark values are not directly comparable.

What changed between base and head:

  • CodSpeed runner v5 changed how benchmarks are measured (base 4.17.1 → head 5.3.1). View release notes

Re-run the base with the same settings to get a valid performance comparison.


Comparing cod-3563-fix-source-file-detection-in-codspeed-jvm-for-kotlinscala (4aacc14) with main (6333555)

Open in CodSpeed

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.

1 participant