Skip to content

GROOVY-11947: Add timing utility methods (timed, timedNanos) and Time…#2654

Open
paulk-asert wants to merge 1 commit into
apache:masterfrom
paulk-asert:groovy11947
Open

GROOVY-11947: Add timing utility methods (timed, timedNanos) and Time…#2654
paulk-asert wants to merge 1 commit into
apache:masterfrom
paulk-asert:groovy11947

Conversation

@paulk-asert

Copy link
Copy Markdown
Contributor

…d record to groovy-jdk

@codecov-commenter

codecov-commenter commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.5732%. Comparing base (449dfeb) to head (88bb9ff).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##               master      #2654        +/-   ##
==================================================
+ Coverage     68.5728%   68.5732%   +0.0004%     
- Complexity      33803      33808         +5     
==================================================
  Files            1524       1525         +1     
  Lines          128128     128139        +11     
  Branches        23289      23289                
==================================================
+ Hits            87861      87869         +8     
- Misses          32468      32469         +1     
- Partials         7799       7801         +2     
Files with missing lines Coverage Δ
src/main/java/groovy/time/Timed.java 100.0000% <100.0000%> (ø)
...aus/groovy/runtime/DefaultGroovyStaticMethods.java 88.7097% <100.0000%> (+1.6726%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds new timing-related Groovy-JDK extension methods on System to measure elapsed execution time (in nanos/millis) and to return a structured result/time pair via a new Timed record.

Changes:

  • Add System.timedNanos(Closure), System.timedMillis(Closure), and System.timed(Closure) extension methods in DefaultGroovyStaticMethods.
  • Introduce groovy.time.Timed (record) to hold the closure result and elapsed nanos, with convenient duration/millis views.
  • Add JUnit tests covering the new System.*timed* APIs and exception propagation.

Reviewed changes

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

File Description
src/test/groovy/org/codehaus/groovy/runtime/DefaultGroovyStaticMethodsTest.groovy Adds tests for the new System.timed* extension methods.
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyStaticMethods.java Implements new timing extension methods using System.nanoTime().
src/main/java/groovy/time/Timed.java Adds a new Timed record to represent (result, nanos) plus derived duration/millis accessors.

@testlens-app

testlens-app Bot commented Jul 2, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 88bb9ff
▶️ Tests: 102450 executed
⚪️ Checks: 31/31 completed


Learn more about TestLens at testlens.app.

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.

3 participants