Skip to content

Commit 131390e

Browse files
committed
switched to using a property instead of a PR option
1 parent bd5999a commit 131390e

2 files changed

Lines changed: 23 additions & 22 deletions

File tree

src/main/java/com/jpetrak/gate/stringannotation/extendedgazetteer/GazetteerBase.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff 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();

src/main/java/com/jpetrak/gate/stringannotation/extendedgazetteer/trie/StoreStates.java

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)