Skip to content

Commit

Permalink
switched to using a property instead of a PR option
Browse files Browse the repository at this point in the history
  • Loading branch information
greenwoodma committed Feb 8, 2024
1 parent bd5999a commit 131390e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,6 @@ public void setGazetteerFeatureSeparator(String sep) {
}
}

protected Boolean profile;

@CreoleParameter(
comment = "If enabled the PR will display information on memory usage etc.",
defaultValue = "false"
)
public void setProfile(Boolean profile) {
this.profile = profile;
}

public Boolean getProfile() {
return profile;
}

public String getGazetteerFeatureSeparator() {
return gazetteerFeatureSeparator;
}
Expand Down Expand Up @@ -201,6 +187,8 @@ public synchronized void incrementGazStore() throws ResourceInstantiationExcepti
String uniqueGazStoreKey = genUniqueGazStoreKey();
logger.info("Creating gazetteer for " + getConfigFileURL());

boolean profile = (System.getProperty("com.jpetrak.gate.stringannotation.profile") != null);

long startTime = 0, before = 0;

if (profile) {
Expand Down Expand Up @@ -247,6 +235,8 @@ public synchronized void replaceGazStore() throws ResourceInstantiationException

long startTime = 0, before = 0;

boolean profile = (System.getProperty("com.jpetrak.gate.stringannotation.profile") != null);

if (profile) {
System.gc();
startTime = System.currentTimeMillis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,27 @@ public void compact() {
if(logger==null) {
logger = Logger.getLogger(this.getClass().getName());
}

boolean profile = (System.getProperty("com.jpetrak.gate.stringannotation.profile") != null);

logger.info("Compacting states");
System.gc();
long startTime = System.currentTimeMillis();
long before = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed();
long startTime = 0, before = 0;

if (profile) {
System.gc();
startTime = System.currentTimeMillis();
before = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed();
}

charMapStore = new StoreCharMapPhase2(charMapStore);
long endTime = System.currentTimeMillis();
long after = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed();
logger.info("Compacting finished in (secs): "+((endTime-startTime)/1000.0));
logger.info("Heap memory increase (estimate,MB): "+
String.format("%01.3f", ((after-before)/(1024.0*1024.0))));

if (profile) {
long endTime = System.currentTimeMillis();
long after = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed();
logger.info("Compacting finished in (secs): "+((endTime-startTime)/1000.0));
logger.info("Heap memory increase (estimate,MB): "+
String.format("%01.3f", ((after-before)/(1024.0*1024.0))));
}
}
}

Expand Down

0 comments on commit 131390e

Please sign in to comment.