Test with disable Discovery manual added Classes
WeldTest.java |
import org.apache.commons.lang3.RandomStringUtils; |
import org.jboss.weld.bean.builtin.BeanManagerProxy; |
import org.jboss.weld.environment.se.Weld; |
import org.jboss.weld.environment.se.WeldContainer; |
import org.junit.Before; |
import org.junit.Test; |
|
import com.google.common.base.Stopwatch; |
|
import javassist.CannotCompileException; |
import javassist.ClassPool; |
|
public class WeldTest { |
|
private static final int CLASS_COUNT = 2000; |
private Class<?>[] classes = new Class<?>[CLASS_COUNT]; |
|
@Before |
public void before() throws CannotCompileException, RuntimeException { |
final ClassPool pool = ClassPool.getDefault(); |
for (int i = 0; i < CLASS_COUNT; i++) { |
classes[i] = pool.makeClass(RandomStringUtils.randomAlphabetic(10)).toClass(); |
} |
} |
|
@Test |
public void test() { |
for (int i = 0; i < 10; i++) { |
run(); |
} |
} |
|
private void run() { |
final Weld weld = new Weld().disableDiscovery(); |
for (final Class<?> clazz : classes) { |
weld.addBeanClass(clazz); |
} |
try (final WeldContainer container = weld.initialize()) { |
final BeanManagerProxy beanManager = (BeanManagerProxy) container.getBeanManager(); |
|
final Stopwatch stopwatch = Stopwatch.createStarted(); |
for (int i = 0; i < 1000; i++) { |
beanManager.instance(); |
} |
System.out.println(container.getId() + " " + stopwatch); |
} |
} |
}
|
Results are the same |