chcchangchc / powermock

Automatically exported from code.google.com/p/powermock
Apache License 2.0
0 stars 0 forks source link

Add possibility to declaratively choose what to byte-code manipulate to gain performance #196

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 8 Feb 2010 at 7:27

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 22 Jul 2010 at 9:23

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 8 Apr 2011 at 8:41

GoogleCodeExporter commented 9 years ago
We have exactly the same issue with performance of PowerMock on Mockito, please 
can you advise whether the fix suggested above will be implemented or not and 
if so, when? Also, please can you describe in more detail how to remove the 
FieldAccess
modification from the expression editor so we can "hack" the code to improve 
our performance temporarily? Many thanks.

Original comment by mandys.i...@gmail.com on 26 Oct 2011 at 8:29

GoogleCodeExporter commented 9 years ago
See https://issues.jboss.org/browse/JASSIST-150

Original comment by bruce.ga...@gmail.com on 6 Feb 2012 at 12:07

GoogleCodeExporter commented 9 years ago
Thanks. Please keep us updated.

Original comment by johan.ha...@gmail.com on 6 Feb 2012 at 12:10

GoogleCodeExporter commented 9 years ago
javassist 3.16.0-GA was released Feb 19, 2012 and has the fix for JASSIST-150. 
This should improve the performnce of the powermock javassist code.
See http://www.csg.ci.i.u-tokyo.ac.jp/~chiba/javassist/
See https://issues.jboss.org/browse/JASSIST/fixforversion/12317222

Original comment by bruce.ga...@gmail.com on 21 Feb 2012 at 6:58

GoogleCodeExporter commented 9 years ago
Great! I tried updating a couple days ago but the artifact was not yet in maven 
central.

Original comment by johan.ha...@gmail.com on 21 Feb 2012 at 8:54