Skip to content

Commit a6a83ab

Browse files
jamesfredleypaulk-asert
authored andcommitted
fix: address Copilot review feedback on benchmark code
Remove unused ExpandoMetaClass import from CallSiteInvalidationBench. Clarify Javadoc on dynamicFinderCalls and mixedCompiledAndDynamicFinders to state that injection cost is intentionally included since these model per-request GORM behavior. Replace System.nanoTime() with a deterministic counter for metaclass property name variation in fullAnalysisWithInvalidation to eliminate unrelated overhead and improve run-to-run comparability.
1 parent 2fc4123 commit a6a83ab

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/grails/CallSiteInvalidationBench.groovy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
*/
1919
package org.apache.groovy.perf.grails
2020

21-
import groovy.lang.ExpandoMetaClass
2221
import groovy.lang.GroovySystem
2322

2423
import org.openjdk.jmh.annotations.*

subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/grails/GrailsWorkloadBench.groovy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class GrailsWorkloadBench {
103103
List<Employee> employees
104104
List<Project> projects
105105
List<Task> tasks
106+
int invalidationCounter
106107

107108
@Setup(Level.Iteration)
108109
void setup() {
@@ -430,7 +431,7 @@ class GrailsWorkloadBench {
430431
@Benchmark
431432
void fullAnalysisWithInvalidation(Blackhole bh) {
432433
// Ongoing framework metaclass activity
433-
PluginConfig.metaClass."preRequest${System.nanoTime() % 3}" = { -> 'init' }
434+
PluginConfig.metaClass."preRequest${invalidationCounter++ % 3}" = { -> 'init' }
434435

435436
// Employee analysis
436437
def activeEmps = employees.findAll { it.isActive }
@@ -444,7 +445,7 @@ class GrailsWorkloadBench {
444445
}
445446

446447
// Mid-request metaclass change
447-
PluginConfig.metaClass."midRequest${System.nanoTime() % 3}" = { -> 'lazy' }
448+
PluginConfig.metaClass."midRequest${invalidationCounter++ % 3}" = { -> 'lazy' }
448449

449450
// Project metrics
450451
def projectSummary = projects.collect { proj ->

subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/grails/MetaclassVariationBench.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ class MetaclassVariationBench {
203203
bh.consume(sum)
204204
}
205205

206-
/** Calling dynamic finders injected via static metaclass. */
206+
/** Injection + invocation of dynamic finders via static metaclass (models per-request GORM cost). */
207207
@Benchmark
208208
void dynamicFinderCalls(Blackhole bh) {
209209
// Inject dynamic finders
@@ -222,7 +222,7 @@ class MetaclassVariationBench {
222222
}
223223
}
224224

225-
/** Mixed compiled method calls and dynamic finder calls. */
225+
/** Mixed compiled method calls and dynamic finder injection + invocation (models per-request GORM cost). */
226226
@Benchmark
227227
void mixedCompiledAndDynamicFinders(Blackhole bh) {
228228
DomainEntity.metaClass.static.findByName = { String n ->

0 commit comments

Comments
 (0)