File tree Expand file tree Collapse file tree
src/main/java/com/jpetrak/gate/stringannotation/extendedgazetteer Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -123,20 +123,6 @@ public void setGazetteerFeatureSeparator(String sep) {
123123 }
124124 }
125125
126- protected Boolean profile ;
127-
128- @ CreoleParameter (
129- comment = "If enabled the PR will display information on memory usage etc." ,
130- defaultValue = "false"
131- )
132- public void setProfile (Boolean profile ) {
133- this .profile = profile ;
134- }
135-
136- public Boolean getProfile () {
137- return profile ;
138- }
139-
140126 public String getGazetteerFeatureSeparator () {
141127 return gazetteerFeatureSeparator ;
142128 }
@@ -201,6 +187,8 @@ public synchronized void incrementGazStore() throws ResourceInstantiationExcepti
201187 String uniqueGazStoreKey = genUniqueGazStoreKey ();
202188 logger .info ("Creating gazetteer for " + getConfigFileURL ());
203189
190+ boolean profile = (System .getProperty ("com.jpetrak.gate.stringannotation.profile" ) != null );
191+
204192 long startTime = 0 , before = 0 ;
205193
206194 if (profile ) {
@@ -247,6 +235,8 @@ public synchronized void replaceGazStore() throws ResourceInstantiationException
247235
248236 long startTime = 0 , before = 0 ;
249237
238+ boolean profile = (System .getProperty ("com.jpetrak.gate.stringannotation.profile" ) != null );
239+
250240 if (profile ) {
251241 System .gc ();
252242 startTime = System .currentTimeMillis ();
Original file line number Diff line number Diff line change @@ -91,16 +91,27 @@ public void compact() {
9191 if (logger ==null ) {
9292 logger = Logger .getLogger (this .getClass ().getName ());
9393 }
94+
95+ boolean profile = (System .getProperty ("com.jpetrak.gate.stringannotation.profile" ) != null );
96+
9497 logger .info ("Compacting states" );
95- System .gc ();
96- long startTime = System .currentTimeMillis ();
97- long before = ManagementFactory .getMemoryMXBean ().getHeapMemoryUsage ().getUsed ();
98+ long startTime = 0 , before = 0 ;
99+
100+ if (profile ) {
101+ System .gc ();
102+ startTime = System .currentTimeMillis ();
103+ before = ManagementFactory .getMemoryMXBean ().getHeapMemoryUsage ().getUsed ();
104+ }
105+
98106 charMapStore = new StoreCharMapPhase2 (charMapStore );
99- long endTime = System .currentTimeMillis ();
100- long after = ManagementFactory .getMemoryMXBean ().getHeapMemoryUsage ().getUsed ();
101- logger .info ("Compacting finished in (secs): " +((endTime -startTime )/1000.0 ));
102- logger .info ("Heap memory increase (estimate,MB): " +
103- String .format ("%01.3f" , ((after -before )/(1024.0 *1024.0 ))));
107+
108+ if (profile ) {
109+ long endTime = System .currentTimeMillis ();
110+ long after = ManagementFactory .getMemoryMXBean ().getHeapMemoryUsage ().getUsed ();
111+ logger .info ("Compacting finished in (secs): " +((endTime -startTime )/1000.0 ));
112+ logger .info ("Heap memory increase (estimate,MB): " +
113+ String .format ("%01.3f" , ((after -before )/(1024.0 *1024.0 ))));
114+ }
104115 }
105116 }
106117
You can’t perform that action at this time.
0 commit comments