Hi All,
It was suggested to me by a colleague that the performance of apt and
the ControlAnnotationProcessor could be increased if caching was
enabled differently. I began to investigating caching of the
VelocityGenerator and later the ControlAnnotationProcessor. After
tinkering around, I found that performance could be increased with a
small change to the ControlAnnotationProcessorFactory to cache the
instance of the ControlAnnotationProcessor.
To test I was using Workshop for Weblogic with a webproject using the
beehive-controls facet.
some not-so-precise perf metrics show the following:
No Changes
First Build - ~30 s
Subsequent Builds - ~25s
Caching of ControlAnnotationProcessor (item4)
First Build - ~28s
Subsequent Build - ~23s
The change is fairly simple (here it is below):
public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
AnnotationProcessorEnvironment env)
{
if(_twoPhaseAnnotationProcessor == null)
_twoPhaseAnnotationProcessor = new
ControlAnnotationProcessor(atds, env);
return _twoPhaseAnnotationProcessor;
}
TwoPhaseAnnotationProcessor _twoPhaseAnnotationProcessor;
and I've attached a small patch in case anyone is interested in checking it out.
Thanks,
-Jacob Danner
Index:
controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlAnnotationProcessorFactory.java
===================================================================
---
controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlAnnotationProcessorFactory.java
(revision 570552)
+++
controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlAnnotationProcessorFactory.java
(working copy)
@@ -59,6 +59,11 @@
public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration>
atds,
AnnotationProcessorEnvironment
env)
{
- return new ControlAnnotationProcessor(atds, env);
+ if(_twoPhaseAnnotationProcessor == null)
+ _twoPhaseAnnotationProcessor = new
ControlAnnotationProcessor(atds, env);
+
+ return _twoPhaseAnnotationProcessor;
}
+
+ TwoPhaseAnnotationProcessor _twoPhaseAnnotationProcessor;
}