-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module rearange and add kotlin benchmark #950
Changes from 13 commits
669356a
b8c0b9d
6f49f26
6766a99
fe9b2e8
94bfe7c
453ed67
f67d20f
a6f8e20
902a33f
1b0b32b
4a27832
b9dc3dc
31f72a4
5fb5630
421759a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,11 +17,20 @@ jobs: | |
uses: gradle/[email protected] | ||
with: | ||
arguments: jmh | ||
- name: Read benchmark result | ||
- name: Merge benchmark results | ||
id: merge | ||
run: | | ||
echo "" > merged_results.csv | ||
find ./fixture-monkey-benchmarks -name 'results.csv' | while read line; do | ||
cat "$line" >> merged_results.csv | ||
echo "" >> merged_results.csv | ||
done | ||
cat merged_results.csv | ||
- name: Read merged benchmark result | ||
id: csv | ||
uses: juliangruber/read-file-action@v1 | ||
with: | ||
path: ./fixture-monkey/build/results/jmh/results.csv | ||
path: merged_results.csv | ||
- name: Create Markdown table | ||
uses: petems/csv-to-md-table-action@master | ||
id: csv-table-output | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
plugins { | ||
id("me.champeau.jmh") version "0.7.2" | ||
`java-test-fixtures` | ||
} | ||
|
||
tasks.jmh{ | ||
enabled = false | ||
} | ||
|
||
subprojects { | ||
tasks.filter { it.name != "jmh" && !it.name.startsWith("compile") && it.name != "jar" } | ||
.forEach { it.enabled = false } | ||
|
||
plugins.apply("me.champeau.jmh") | ||
plugins.apply("java-test-fixtures") | ||
|
||
dependencies { | ||
jmhImplementation(project(":fixture-monkey-javax-validation")) | ||
jmhImplementation(project(":fixture-monkey-jackson")) | ||
jmhImplementation("org.openjdk.jmh:jmh-core:${Versions.JMH}") | ||
jmhImplementation("org.openjdk.jmh:jmh-generator-annprocess:${Versions.JMH}") | ||
jmhImplementation("org.projectlombok:lombok:${Versions.LOMBOK}") | ||
jmhAnnotationProcessor("org.projectlombok:lombok:${Versions.LOMBOK}") | ||
|
||
testFixturesApi(project(":fixture-monkey-javax-validation")) | ||
testFixturesApi("org.openjdk.jmh:jmh-core:${Versions.JMH}") | ||
testFixturesApi("org.openjdk.jmh:jmh-generator-annprocess:${Versions.JMH}") | ||
testFixturesApi("org.projectlombok:lombok:${Versions.LOMBOK}") | ||
testFixturesAnnotationProcessor("org.projectlombok:lombok:${Versions.LOMBOK}") | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
plugins { | ||
id("org.jetbrains.kotlin.jvm") version Versions.KOTLIN | ||
id("org.jlleitschuh.gradle.ktlint") version Versions.KTLINT | ||
id("com.navercorp.fixturemonkey.gradle.plugin.maven-publish-conventions") | ||
} | ||
|
||
dependencies { | ||
api(project(":fixture-monkey-kotlin")) | ||
jmhImplementation(testFixtures(project(":fixture-monkey-benchmarks:fixture-monkey-benchmark"))) | ||
} | ||
|
||
jmh { | ||
fork = 1 | ||
warmupIterations = 3 | ||
iterations = 10 | ||
resultFormat = "CSV" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.navercorp.fixturemonkey.kotlin | ||
|
||
import com.navercorp.fixturemonkey.OrderSheet | ||
import com.navercorp.fixturemonkey.FixtureMonkey | ||
import com.navercorp.fixturemonkey.api.introspector.BeanArbitraryIntrospector | ||
import com.navercorp.fixturemonkey.api.type.TypeCache | ||
import java.util.concurrent.TimeUnit | ||
import org.openjdk.jmh.annotations.Benchmark | ||
import org.openjdk.jmh.annotations.BenchmarkMode | ||
import org.openjdk.jmh.annotations.Level | ||
import org.openjdk.jmh.annotations.Mode | ||
import org.openjdk.jmh.annotations.OutputTimeUnit | ||
import org.openjdk.jmh.annotations.Scope | ||
import org.openjdk.jmh.annotations.Setup | ||
import org.openjdk.jmh.annotations.State | ||
import org.openjdk.jmh.infra.Blackhole | ||
|
||
private const val COUNT = 500 | ||
|
||
@BenchmarkMode(Mode.AverageTime) | ||
@OutputTimeUnit(TimeUnit.MILLISECONDS) | ||
@State(Scope.Benchmark) | ||
open class KotlinObjectGenerationBenchMark { | ||
@Setup(value = Level.Iteration) | ||
fun setUp() { | ||
TypeCache.clearCache() | ||
} | ||
|
||
@Benchmark | ||
fun beanGenerateJavaOrderSheetWithFixtureMonkey(blackhole: Blackhole) { | ||
val fixtureMonkey = FixtureMonkey.builder() | ||
.plugin(KotlinPlugin()) | ||
.objectIntrospector(BeanArbitraryIntrospector.INSTANCE) | ||
.build() | ||
blackhole.consume(generateJavaOrderSheet(fixtureMonkey)) | ||
} | ||
|
||
private fun generateJavaOrderSheet(fixtureMonkey: FixtureMonkey): List<OrderSheet> = | ||
List(COUNT) { fixtureMonkey.giveMeOne(OrderSheet::class.java) } | ||
|
||
@Benchmark | ||
fun beanGenerateKotlinOrderSheetWithFixtureMonkey(blackhole: Blackhole) { | ||
val fixtureMonkey = FixtureMonkey.builder() | ||
.plugin(KotlinPlugin()) | ||
.build() | ||
blackhole.consume(generateKotlinOrderSheet(fixtureMonkey)) | ||
} | ||
|
||
private fun generateKotlinOrderSheet(fixtureMonkey: FixtureMonkey): List<KotlinOrderSheet> = | ||
List(COUNT) { fixtureMonkey.giveMeOne(KotlinOrderSheet::class.java) } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package com.navercorp.fixturemonkey.kotlin | ||
|
||
import java.math.BigDecimal | ||
import java.time.Instant | ||
import javax.validation.constraints.Size | ||
|
||
data class KotlinOrderSheet( | ||
val id: String, | ||
val backUrl: String?, | ||
val userNo: Long?, | ||
@field:Size(min = 1, max = 1) | ||
val products: List<OrderSheetProduct>, | ||
val merchantsByMerchantNo: Map.Entry<Long, OrderSheetMerchant>?, | ||
val registeredDateTime: Instant?, | ||
@field:Size(min = 1, max = 1) | ||
val bundleDeliveryFeesByDeliveryGroupKey: Map<String, OrderSheetBundleDeliveryFee>? | ||
) { | ||
data class OrderSheetProduct( | ||
val id: String, | ||
val productName: String?, | ||
val salePrice: BigDecimal?, | ||
val ecMallProductId: String?, | ||
@field:Size(min = 1, max = 1) | ||
val items: List<OrderSheetItem>, | ||
val deliveryPolicy: OrderSheetDeliveryPolicy?, | ||
val merchantNo: Long, | ||
val merchantCategoryItemTypeName: String?, | ||
val wholeCategoryId: String?, | ||
val naverBenefit: Boolean, | ||
val deliveryFee: OrderSheetDeliveryFee?, | ||
val rewardPointPolicy: OrderSheetRewardPointPolicy? | ||
) | ||
|
||
data class OrderSheetItem( | ||
val id: String, | ||
val itemNo: String?, | ||
val price: BigDecimal?, | ||
val quantity: Long?, | ||
val orderAmount: BigDecimal?, | ||
@field:Size(min = 1, max = 1) | ||
val elements: List<OrderSheetElement> | ||
) | ||
|
||
data class OrderSheetElement( | ||
val id: String, | ||
val elementType: ElementType, | ||
@field:Size(min = 1, max = 1) | ||
val names: List<String>, | ||
@field:Size(min = 1, max = 1) | ||
val valueIds: List<String>, | ||
@field:Size(min = 1, max = 1) | ||
val texts: List<String> | ||
) | ||
|
||
data class OrderSheetMerchant( | ||
val talkInterlockAccountId: String?, | ||
val logeyeRequestId: String?, | ||
val logeyeInflowPathName: String?, | ||
val logeyePayAccumulation: Boolean? | ||
) | ||
|
||
data class OrderSheetDeliveryPolicy( | ||
val deliveryMethodType: DeliveryMethodType, | ||
val deliveryFeeClassType: DeliveryFeeClassType, | ||
val deliveryFeePayType: DeliveryFeePayType, | ||
val baseFee: BigDecimal?, | ||
val bundlePolicy: OrderSheetDeliveryBundlePolicy?, | ||
val freeConditionalAmount: BigDecimal? | ||
) | ||
|
||
data class OrderSheetDeliveryBundlePolicy( | ||
val bundleGroupId: String? | ||
) | ||
|
||
data class OrderSheetDeliveryFee( | ||
val deliveryFee: BigDecimal?, | ||
val deliveryGroupKey: String? | ||
) | ||
|
||
data class OrderSheetBundleDeliveryFee( | ||
val deliveryFee: BigDecimal?, | ||
val type: BundleType | ||
) | ||
|
||
data class OrderSheetRewardPointPolicy( | ||
val purchasePolicyNo: Long?, | ||
val purchaseAccumulateAmount: BigDecimal? | ||
) | ||
|
||
enum class DeliveryMethodType { | ||
DELIVERY, VISIT_RECEIPT, DIRECT_DELIVERY, QUICK_SVC, NOTHING | ||
} | ||
|
||
enum class ElementType { | ||
OPTION, CUSTOM | ||
} | ||
|
||
enum class DeliveryFeeClassType { | ||
CHARGE, FREE | ||
} | ||
|
||
enum class DeliveryFeePayType { | ||
PRE_PAY, AFTER_PAY, FREE | ||
} | ||
|
||
enum class BundleType { | ||
MANUALLY, IDENTICAL_PRODUCT | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
plugins { | ||
id("com.navercorp.fixturemonkey.gradle.plugin.java-conventions") | ||
} | ||
|
||
dependencies { | ||
api(project(":fixture-monkey")) | ||
} | ||
|
||
jmh { | ||
fork = 1 | ||
warmupIterations = 3 | ||
iterations = 10 | ||
resultFormat = "CSV" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,4 +174,3 @@ public enum BundleType { | |
IDENTICAL_PRODUCT | ||
} | ||
} | ||
|
||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,4 +180,3 @@ public enum BundleType { | |
IDENTICAL_PRODUCT | ||
} | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. EOL is missing now. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ dependencies { | |
implementation("org.jetbrains.kotlin:kotlin-reflect:${Versions.KOTLIN}") | ||
|
||
testImplementation(project(":fixture-monkey-jackson")) | ||
testImplementation(project(":fixture-monkey-javax-validation")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this dependency necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the ExpressionGeneratorJavaTestSpecs, javax validation was previously being used. Even on the main branch, compile was not successful in my local environment, the exact reason is unclear. After changing modules, ci compile fails in the absence of the dependency, so it necessary in the current situation. |
||
testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin") | ||
testImplementation("org.junit.jupiter:junit-jupiter-engine:${Versions.JUNIT_JUPITER}") | ||
testImplementation("org.junit.platform:junit-platform-engine:${Versions.JUNIT_ENGINE}") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
package com.navercorp.fixturemonkey.kotlin; | ||
package com.navercorp.fixturemonkey.kotlin.spec; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this change has nothing to do with this PR. |
||
|
||
import java.util.List; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,8 @@ | |
|
||
package com.navercorp.fixturemonkey.kotlin | ||
|
||
import com.navercorp.fixturemonkey.kotlin.ExpressionGeneratorJavaTestSpecs.DogJava | ||
import com.navercorp.fixturemonkey.kotlin.ExpressionGeneratorJavaTestSpecs.PersonJava | ||
import com.navercorp.fixturemonkey.kotlin.spec.ExpressionGeneratorJavaTestSpecs.DogJava | ||
import com.navercorp.fixturemonkey.kotlin.spec.ExpressionGeneratorJavaTestSpecs.PersonJava | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this change has nothing to do with this PR. |
||
import org.assertj.core.api.BDDAssertions.then | ||
import org.junit.jupiter.api.Test | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EOL is missing now.