The byte-code manipulation of Javassist can be slow in some occasions which
have may lead to performance issues for certain classes/frameworks. Take
for example the demo.org.powermock.examples.Log4jUserTest, it takes about
2-3s before the test actually starts. The reason is the that
PowerMockExpressionEditor takes a lot of time to process. Perhaps we could
optimize this expression editor or we could let the user specify what needs
to be byte-code manipulated. E.g. when I remove the FieldAccess
modification from the expression editor the transformation of
org.apache.log4j.Category falls from 516 to 147 ms (which is still high)
and the test still pass. It would be good if you could statically specify
what to byte-code manipulate in these cases.
E.g.
@PrepareForTest({A.class, B.class}, type={CONSTRUCTORS, METHODS, FIELDS})
@PrepareForTest({C.class}, type={METHODS})
and/or
@PrepareForTest({A.class}, excludeFromDefaultTypes={FIELDS})
and/or
@PrepareForTest(value=A.class, byteCodeManipulationScheme=MyScheme.class)
Using this approach a user with performance problems could optimize
PowerMock's byte-code manipulation scheme. This should of course also be
configurable from a mock policy.
Original issue reported on code.google.com by johan.ha...@gmail.com on 8 Nov 2009 at 8:12
Original issue reported on code.google.com by
johan.ha...@gmail.com
on 8 Nov 2009 at 8:12