bengbengbalabalabeng commented on issue #69:
URL: https://github.com/apache/fesod/issues/69#issuecomment-3796104660
@xbo2018 Hi.
I tried performance test on 100k records shows a **~800x performance gap**:
- `BeanMap`: **~5.8 ms**
- `NoCglibBeanMap`: **~4,600 ms**
<details>
<summary>Click To Review Full Code</summary>
```java
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@State(Scope.Thread)
@Fork(1)
@Warmup(iterations = 3, time = 1)
@Measurement(iterations = 5, time = 1)
public class BeanMapBenchmark {
@Param({"10000", "50000", "100000"})
private int size;
private TypeTestObject[] sourceBeans;
private int[] newIntValues;
private static final String KEY_GET = "testString";
private static final String KEY_PUT = "testPrimitiveInt";
@Setup(Level.Trial)
public void setup() {
sourceBeans = new TypeTestObject[size];
newIntValues = new int[size];
for (int i = 0; i < size; i++) {
sourceBeans[i] = TypeTestObject.builder()
.testString("Data Row " + i)
.testPrimitiveInt(i)
.build();
newIntValues[i] = i + 9999;
}
}
@Benchmark
public void cglib_Create_And_Get(Blackhole bh) {
for (int i = 0; i < size; i++) {
TypeTestObject bean = sourceBeans[i];
BeanMap map = BeanMap.create(bean);
bh.consume(map.get(bean, KEY_GET));
}
}
@Benchmark
public void reflect_Create_And_Get(Blackhole bh) {
for (int i = 0; i < size; i++) {
TypeTestObject bean = sourceBeans[i];
BeanMap map = NoCglibBeanMap.create(bean);
bh.consume(map.get(bean, KEY_GET));
}
}
@Benchmark
public void cglib_Create_And_Put(Blackhole bh) {
for (int i = 0; i < size; i++) {
TypeTestObject bean = sourceBeans[i];
BeanMap map = BeanMap.create(bean);
bh.consume(map.put(bean, KEY_PUT, newIntValues[i]));
}
}
@Benchmark
public void reflect_Create_And_Put(Blackhole bh) {
for (int i = 0; i < size; i++) {
TypeTestObject bean = sourceBeans[i];
BeanMap map = NoCglibBeanMap.create(bean);
bh.consume(map.put(bean, KEY_PUT, newIntValues[i]));
}
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(BeanMapBenchmark.class.getSimpleName())
.build();
new Runner(opt).run();
}
}
```
</details>
Output:
```log
Benchmark (size) Mode Cnt Score
Error Units
BeanMapBenchmark.cglib_Create_And_Get 10000 avgt 5 0.542 ±
0.390 ms/op
BeanMapBenchmark.cglib_Create_And_Get 50000 avgt 5 2.693 ±
0.498 ms/op
BeanMapBenchmark.cglib_Create_And_Get 100000 avgt 5 5.854 ±
2.103 ms/op
BeanMapBenchmark.cglib_Create_And_Put 10000 avgt 5 0.558 ±
0.189 ms/op
BeanMapBenchmark.cglib_Create_And_Put 50000 avgt 5 3.041 ±
0.949 ms/op
BeanMapBenchmark.cglib_Create_And_Put 100000 avgt 5 5.696 ±
0.231 ms/op
BeanMapBenchmark.reflect_Create_And_Get 10000 avgt 5 458.933 ±
107.278 ms/op
BeanMapBenchmark.reflect_Create_And_Get 50000 avgt 5 2281.279 ±
472.617 ms/op
BeanMapBenchmark.reflect_Create_And_Get 100000 avgt 5 4642.381 ±
911.832 ms/op
BeanMapBenchmark.reflect_Create_And_Put 10000 avgt 5 484.927 ±
193.778 ms/op
BeanMapBenchmark.reflect_Create_And_Put 50000 avgt 5 2324.239 ±
518.657 ms/op
BeanMapBenchmark.reflect_Create_And_Put 100000 avgt 5 4524.777 ±
634.290 ms/op
```
The performance of `NoCglibBeanMap` implementation drops significantly in
large-scale data scenarios.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]