neoremind commented on a change in pull request #1880: Make ubenchmark clases 
executable from IDEA
URL: https://github.com/apache/calcite/pull/1880#discussion_r399361115
 
 

 ##########
 File path: ubenchmark/build.gradle.kts
 ##########
 @@ -22,12 +22,29 @@ dependencies {
     // Make jmhCompileClasspath resolvable
     @Suppress("DEPRECATION")
     jmhCompileClasspath(platform(project(":bom")))
-    jmh(project(":core"))
-    jmh(project(":linq4j"))
-    jmh("com.google.guava:guava")
-    jmh("org.codehaus.janino:commons-compiler")
-    jmh("org.openjdk.jmh:jmh-core")
-    jmh("org.openjdk.jmh:jmh-generator-annprocess")
+    jmhImplementation(project(":core"))
+    jmhImplementation(project(":linq4j"))
+    jmhImplementation("com.google.guava:guava")
+    jmhImplementation("org.codehaus.janino:commons-compiler")
+    jmhImplementation("org.openjdk.jmh:jmh-core")
+    jmhImplementation("org.openjdk.jmh:jmh-generator-annprocess")
 }
 
 // See https://github.com/melix/jmh-gradle-plugin
+// Unfortunately, current jmh-gradle-plugin does not allow to cusomize jmh 
parameters from the
+// command line, so the workarounds are:
+// a) Build and execute the jar itself: ./gradlew jmhJar && java -jar 
build/libs/calcite-...jar JMH_OPTIONS
+// b) Execute benchmarks via .main() methods from IDE (you might want to 
activate "power save mode"
+//    in the IDE to minimize the impact of the IDE itself on the benchmark 
results)
+
+tasks.withType<JavaExec>().configureEach {
+    // Execution of .main methods from IDEA should re-generate benchmark 
classes if required
+    dependsOn("jmhCompileGeneratedClasses")
+    doFirst {
+        // At best jmh plugin should add the generated directories to the 
Gradle model, however,
+        // currently it builds the jar only :-/
+        // IntelliJ IDEA "execute main method" adds a JavaExec task, so we 
configure it
+        classpath(File(buildDir, "jmh-generated-classes"))
+        classpath(File(buildDir, "jmh-generated-resources"))
 
 Review comment:
   Would you try creating a new test or renaming test method? Maybe you can 
reproduce the exception as below. 
   Sorry about the Chinese character. Literally, it means *Error: Symbol not 
found* 
   ```
   
/Users/xu/IdeaProjects/my-calcite/ubenchmark/build/jmh-generated-sources/org/apache/calcite/benchmarks/generated/ReflectiveVisitDispatcherTest_testReflectiveVisitorDispatcherInvokeInstanceCachingUseMethodHandle_jmhTest.java:78:
 错误: 找不到符号
                   
blackhole.consume(l_reflectivevisitdispatchertest0_G.testReflectiveVisitorDispatcherInvokeInstanceCachingUseMethodHandle());
                                                                       ^
     符号:   方法 
testReflectiveVisitorDispatcherInvokeInstanceCachingUseMethodHandle()
     位置: 类型为ReflectiveVisitDispatcherTest_jmhType的变量 
l_reflectivevisitdispatchertest0_G
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to