Revision: 7822
          
http://languagetool.svn.sourceforge.net/languagetool/?rev=7822&view=rev
Author:   dnaber
Date:     2012-08-09 20:11:52 +0000 (Thu, 09 Aug 2012)
Log Message:
-----------
better performance logging, setting search timeout from here (was 5000ms before 
anyway)

Modified Paths:
--------------
    
trunk/ltcommunity/grails-app/controllers/org/languagetool/RuleEditorController.groovy

Modified: 
trunk/ltcommunity/grails-app/controllers/org/languagetool/RuleEditorController.groovy
===================================================================
--- 
trunk/ltcommunity/grails-app/controllers/org/languagetool/RuleEditorController.groovy
       2012-08-09 05:37:19 UTC (rev 7821)
+++ 
trunk/ltcommunity/grails-app/controllers/org/languagetool/RuleEditorController.groovy
       2012-08-09 20:11:52 UTC (rev 7822)
@@ -35,6 +35,7 @@
 
     int CORPUS_MATCH_LIMIT = 20
     int EXPERT_MODE_CORPUS_MATCH_LIMIT = 100
+    int SEARCH_TIMEOUT_MILLIS = 5000
 
     def index = {
         List languageNames = getLanguageNames()
@@ -95,18 +96,22 @@
             render(template: 'checkRuleProblem', model: [problems: problems, 
hasRegex: hasRegex(patternRule), expertMode: true])
             return
         }
+        long startTime = System.currentTimeMillis()
         SearcherResult searcherResult = checkRuleAgainstCorpus(patternRule, 
language, EXPERT_MODE_CORPUS_MATCH_LIMIT)
+        long searchTime = System.currentTimeMillis() - startTime
+        log.info("Checked XML in ${language}, timeout 
(${SEARCH_TIMEOUT_MILLIS}ms) triggered: ${searcherResult.resultIsTimeLimited}, 
time: ${searchTime}ms")
         render(view: '_corpusResult', model: [searcherResult: searcherResult, 
expertMode: true, limit: EXPERT_MODE_CORPUS_MATCH_LIMIT])
     }
 
     SearcherResult checkRuleAgainstCorpus(PatternRule patternRule, Language 
language, int maxHits) {
         Searcher searcher = new Searcher()  // TODO: move to service?
         searcher.setMaxHits(maxHits)
+        searcher.setMaxSearchTimeMillis(SEARCH_TIMEOUT_MILLIS)
         String indexDirTemplate = grailsApplication.config.fastSearchIndex
         File indexDir = new File(indexDirTemplate.replace("LANG", 
language.getShortName()))
         if (indexDir.isDirectory()) {
             IndexSearcher indexSearcher = new 
IndexSearcher(FSDirectory.open(indexDir))
-            SearcherResult searcherResult
+            SearcherResult searcherResult = null
             try {
               searcherResult = searcher.findRuleMatchesOnIndex(patternRule, 
language, indexSearcher)
             } finally {

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Languagetool-cvs mailing list
Languagetool-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/languagetool-cvs

Reply via email to