>

Kotlin 용 JMH 플러그인을 사용하여 벤치 마크 테스트를 만들려고합니다. 프로젝트는 gradle에 의해 빌드되고 Spring Boot를 사용합니다. 제공된 작업 (./gradlew jmh)을 사용 하여이 테스트를 실행하고 싶습니다. 저는 작동하지 않습니다.

명령을 사용하여이 코드를 실행합니다

./gradlew jmh

내 build.gradle.kts는 다음과 같습니다.

import info.solidsoft.gradle.pitest.PitestPluginExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("me.champeau.gradle:jmh-gradle-plugin:0.4.8")
    }
}
plugins {
    id("idea")
    id("org.springframework.boot") version "2.1.6.RELEASE"
    id("io.spring.dependency-management") version "1.0.8.RELEASE"
    kotlin("jvm") version "1.3.21"
    kotlin("plugin.spring") version "1.3.21"
    id("me.champeau.gradle.jmh") version "0.4.8"
}
jmh {
    isIncludeTests = true
}
tasks.bootJar {
    archiveFileName.set("XXX.jar")
    archiveVersion.set("0.1.0")
}
repositories {
    mavenCentral()
    maven { setUrl("http://oss.jfrog.org/artifactory/oss-snapshot-local/") }
}
dependencyManagement {
    dependencies {
        (...)
        dependency("org.openjdk.jmh:jmh-core:1.21")
        dependency("org.openjdk.jmh:jmh-generator-annprocess:1.21")
        dependency("org.openjdk.jmh:jmh-generator-bytecode:1.21")
    }
}
dependencies {
    (...)
    jmh("org.openjdk.jmh:jmh-core")
    jmh("org.openjdk.jmh:jmh-generator-annprocess")
    jmh("org.openjdk.jmh:jmh-generator-bytecode")
    jmh("org.springframework.boot:spring-boot-starter-test")
    jmh("org.junit.jupiter:junit-jupiter-api")
    jmh("org.junit.jupiter:junit-jupiter-params")
    jmh("org.assertj:assertj-core")
    jmh("io.projectreactor:reactor-test")
    jmh("org.springframework.boot:spring-boot-starter-webflux")
}
tasks.test {
    useJUnitPlatform()
}
tasks.integrationTest {
    useJUnitPlatform()
}
tasks.withType<KotlinCompile>().configureEach {
    kotlinOptions.jvmTarget = "1.8"
}

다음 테스트 :

@BenchmarkMode(Mode.All)
@State(Scope.Benchmark)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Fork(0, jvmArgsAppend = ["-XX:+PrintGCDetails"])
@Warmup(iterations = 1)
@Measurement(iterations = 3)
@ExtendWith(SpringExtension::class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
open class StorageObjectControllerTest {
    private lateinit var context: ApplicationContext
    @Test
    fun setup() {
        val opt = OptionsBuilder()
            .include(this.javaClass.name)
            .threads(1)
            .build()
        Runner(opt).run()
    }
    @Setup
    fun init() {
        // add test data
    }
    @TearDown
    fun cleanup() {
        // remove data after test
    }
    @Benchmark
    @BenchmarkMode(Mode.AverageTime)
    fun latency_getAllObjects() {
        (...)
    }
    @Benchmark
    @BenchmarkMode(Mode.Throughput)
    fun throughput_getAllObjects() {
        (...)
    }
}

오류 :

ava.io.FileNotFoundException: class path resource [org/springframework/web/reactive/config/WebFluxConfigurationSupport.class] cannot be opened because it does not exist
        at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:180)
        at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:51)
        at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103)
        at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:123)
        at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:81)
        at org.springframework.context.annotation.ConfigurationClassParser.retrieveBeanMethodMetadata(ConfigurationClassParser.java:399)



java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.
        at org.springframework.util.Assert.notEmpty(Assert.java:464)
        at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getCandidateConfigurations(AutoConfigurationImportSelector.java:173)
        at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getAutoConfigurationEntry(AutoConfigurationImportSelector.java:116)
        at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector$AutoConfigurationGroup.process(AutoConfigurationImportSelector.java:396)
        at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGrouping.getImports(ConfigurationClassParser.java:875)

도움을주세요


  • 답변 # 1

    테스트에 @RunWith (SpringRunner.class)를 추가 할 수 있다고 생각합니다. 스프링 테스트 + jmh

    에서 자세한 내용을 확인할 수 있습니다.

  • 이전 c - cmake로 컴파일하는 동안 오류가 발생했습니다 - -ldwmapi를 찾을 수 없습니다
  • 다음 automationanywhere - 어디서나 자동화로 내 컴퓨터에 다운로드 된 html 파일의 제목을 가져옵니다