|
|
|
|
@@ -0,0 +1,70 @@
|
|
|
|
|
/*
|
|
|
|
|
* Copyright 2023 the original author or authors.
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
package org.springframework.data.relational.core.mapping;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import org.junit.platform.commons.annotation.Testable;
|
|
|
|
|
import org.openjdk.jmh.annotations.Benchmark;
|
|
|
|
|
import org.openjdk.jmh.annotations.Scope;
|
|
|
|
|
import org.openjdk.jmh.annotations.Setup;
|
|
|
|
|
import org.openjdk.jmh.annotations.State;
|
|
|
|
|
import org.springframework.data.annotation.Id;
|
|
|
|
|
import org.springframework.data.relational.BenchmarkSettings;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author Mark Paluch
|
|
|
|
|
*/
|
|
|
|
|
@Testable
|
|
|
|
|
public class AggregatePathBenchmark extends BenchmarkSettings {
|
|
|
|
|
|
|
|
|
|
@Benchmark
|
|
|
|
|
public Object measureAggregatePathAppend(StateHolder holder) {
|
|
|
|
|
|
|
|
|
|
holder.context.getAggregatePath(holder.persistentEntity)
|
|
|
|
|
.append(holder.persistentEntity.getRequiredPersistentProperty("id"));
|
|
|
|
|
holder.context.getAggregatePath(holder.persistentEntity)
|
|
|
|
|
.append(holder.persistentEntity.getRequiredPersistentProperty("name"));
|
|
|
|
|
return holder.context.getAggregatePath(holder.persistentEntity)
|
|
|
|
|
.append(holder.persistentEntity.getRequiredPersistentProperty("trivials"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Benchmark
|
|
|
|
|
public Object measureGetAggregatePathAppend(StateHolder holder) {
|
|
|
|
|
|
|
|
|
|
return holder.context.getAggregatePath(holder.persistentEntity)
|
|
|
|
|
.append(holder.persistentEntity.getRequiredPersistentProperty("id"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@State(Scope.Benchmark)
|
|
|
|
|
public static class StateHolder {
|
|
|
|
|
|
|
|
|
|
RelationalMappingContext context = new RelationalMappingContext();
|
|
|
|
|
|
|
|
|
|
RelationalPersistentEntity<?> persistentEntity;
|
|
|
|
|
|
|
|
|
|
@Setup
|
|
|
|
|
public void setup() {
|
|
|
|
|
persistentEntity = context.getRequiredPersistentEntity(SingleReferenceAggregate.class);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
record TrivialAggregate(@Id Long id, String name) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
record SingleReferenceAggregate(@Id Long id, String name, List<TrivialAggregate> trivials) {
|
|
|
|
|
}
|
|
|
|
|
}
|