use of org.qi4j.api.value.ValueBuilderFactory in project qi4j-sdk by Qi4j.
the class CompositeCreationPerformanceTest method newInstanceForRegisteredCompositePerformance.
@Test
public void newInstanceForRegisteredCompositePerformance() throws ActivationException, AssemblyException {
SingletonAssembler assembler = new SingletonAssembler() {
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
module.transients(AnyComposite.class);
module.objects(AnyObject.class);
module.values(AnyValue.class);
}
};
int loops = 2;
long t0 = 0;
{
for (int i = 0; i < loops; i++) {
t0 = t0 + testJavaObjectCreationPerformance();
}
t0 = t0 / loops;
}
long t1 = 0;
{
TransientBuilderFactory module = assembler.module();
for (int i = 0; i < loops; i++) {
t1 = t1 + testCompositeCreationPerformance(module);
}
t1 = t1 / loops;
}
long t2 = 0;
{
ObjectFactory objectFactory = assembler.module();
for (int i = 0; i < loops; i++) {
t2 = t2 + testObjectCreationPerformance(objectFactory);
}
t2 = t2 / loops;
}
long t3 = 0;
{
ValueBuilderFactory valueBuilderFactory = assembler.module();
for (int i = 0; i < loops; i++) {
t3 = t3 + testValueCreationPerformance(valueBuilderFactory);
}
t3 = t3 / loops;
}
long t4 = 0;
{
TransientBuilderFactory module = assembler.module();
for (int i = 0; i < loops; i++) {
t4 = t4 + testCompositeCreationWithBuilderPerformance(module);
}
t4 = t4 / loops;
}
long t6 = 0;
{
ValueBuilderFactory valueBuilderFactory = assembler.module();
for (int i = 0; i < loops; i++) {
t6 = t6 + testValueCreationWithBuilderPerformance(valueBuilderFactory);
}
t6 = t6 / loops;
}
System.out.println("Transient: " + (t1 / t0) + "x");
System.out.println("TransientBuilder: " + (t4 / t0) + "x");
System.out.println("Value: " + (t3 / t0) + "x");
System.out.println("ValueBuilder: " + (t6 / t0) + "x");
System.out.println("Object: " + (t2 / t0) + "x");
}
Aggregations