diff --git a/src/main/java/com/jpetrak/gate/stringannotation/extendedgazetteer/GazetteerBase.java b/src/main/java/com/jpetrak/gate/stringannotation/extendedgazetteer/GazetteerBase.java index 1314394..4fc6466 100644 --- a/src/main/java/com/jpetrak/gate/stringannotation/extendedgazetteer/GazetteerBase.java +++ b/src/main/java/com/jpetrak/gate/stringannotation/extendedgazetteer/GazetteerBase.java @@ -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; } @@ -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) { @@ -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(); diff --git a/src/main/java/com/jpetrak/gate/stringannotation/extendedgazetteer/trie/StoreStates.java b/src/main/java/com/jpetrak/gate/stringannotation/extendedgazetteer/trie/StoreStates.java index 4024345..e87aba4 100644 --- a/src/main/java/com/jpetrak/gate/stringannotation/extendedgazetteer/trie/StoreStates.java +++ b/src/main/java/com/jpetrak/gate/stringannotation/extendedgazetteer/trie/StoreStates.java @@ -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)))); + } } }