コード例 #1
0
ファイル: Profiler.cs プロジェクト: achoudh5/prando
        /// <summary>Track memoization</summary>
        /// <remarks>
        /// This is not part of standard debug interface but is triggered by
        /// profiling.  Code gen inserts an override for this method in the
        /// recognizer, which triggers this method.
        /// </remarks>
        public void ExamineRuleMemoization(IIntStream input, int ruleIndex, string ruleName)
        {
            int stopIndex = parser.GetRuleMemoization(ruleIndex, input.Index());

            if (stopIndex == BaseRecognizer.MEMO_RULE_UNKNOWN)
            {
                numMemoizationCacheMisses++;
                numGuessingRuleInvocations++;                 // we'll have to enter
            }
            else
            {
                // regardless of rule success/failure, if in cache, we have a cache hit
                numMemoizationCacheHits++;
            }
        }
コード例 #2
0
        /** <summary>
         *  Track memoization; this is not part of standard debug interface
         *  but is triggered by profiling.  Code gen inserts an override
         *  for this method in the recognizer, which triggers this method.
         *  </summary>
         */
        public virtual void ExamineRuleMemoization(IIntStream input,
                                                   int ruleIndex,
                                                   string ruleName)
        {
            //System.out.println("examine memo "+ruleName);
            int stopIndex = parser.GetRuleMemoization(ruleIndex, input.Index);

            if (stopIndex == BaseRecognizer.MEMO_RULE_UNKNOWN)
            {
                //System.out.println("rule "+ruleIndex+" missed @ "+input.index());
                numMemoizationCacheMisses++;
                numGuessingRuleInvocations++; // we'll have to enter
            }
            else
            {
                // regardless of rule success/failure, if in cache, we have a cache hit
                //System.out.println("rule "+ruleIndex+" hit @ "+input.index());
                numMemoizationCacheHits++;
            }
        }