Changeset 396

Show
Ignore:
Timestamp:
08/06/10 13:09:16 (2 years ago)
Author:
ke
Message:

First steps towards execution profiler.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • kahina/trunk/src/org/kahina/lp/bridge/LogicProgrammingBridge.java

    r387 r396  
    2222public class LogicProgrammingBridge extends KahinaBridge 
    2323{ 
    24         private static final boolean verbose = false; 
     24        private static final boolean VERBOSE = false; 
    2525 
    2626        // a dynamic map from external step IDs to most recent corresponding tree 
     
    5252                KahinaRunner.getControl().registerListener(KahinaEventTypes.SYSTEM, this); 
    5353                KahinaRunner.getControl().registerListener(KahinaEventTypes.SELECTION, this); 
    54                 if (verbose
     54                if (VERBOSE
    5555                        System.err.println("new LogicProgrammingBridge()"); 
    5656        } 
     
    6565        public int convertStepID(int extID) 
    6666        { 
    67                 if (verbose
     67                if (VERBOSE
    6868                        System.err.println("LogicProgrammingBridge.convertStepID(" + extID + ")"); 
    6969                Integer intID = stepIDConv.get(extID); 
     
    7676                        stepIDConv.put(extID, intID); 
    7777                } 
    78                 if (verbose
     78                if (VERBOSE
    7979                        System.err.println("LogicProgrammingBridge.convertStepID(" + extID + ") = " + intID); 
    8080                return intID; 
     
    8585                try 
    8686                { 
    87                         if (verbose
     87                        if (VERBOSE
    8888                                System.err.println("LogicProgrammingBridge.registerStepInformation(" + extID + ",\"" + nodeLabel + "\")"); 
    8989                        int stepID = convertStepID(extID); 
     
    9595                        currentID = stepID; 
    9696                        state.consoleMessage(stepID, extID, LogicProgrammingStepType.CALL, consoleMessage); 
    97                         if (verbose
     97                        if (VERBOSE
    9898                                System.err.println("//LogicProgrammingBridge.registerStepInformation(" + extID + ",\"" + nodeLabel + "\")"); 
    9999                } catch (Exception e) 
     
    108108                try 
    109109                { 
    110                         if (verbose
     110                        if (VERBOSE
    111111                                System.err.println("LogicProgrammingBridge.registerStepSourceCodeLocation(" + extID + ",\"" + absolutePath + "\"," + lineNumber + ")"); 
    112112                        int stepID = convertStepID(extID); 
     
    126126                try 
    127127                { 
    128                         if (verbose
     128                        if (VERBOSE
    129129                                System.err.println("LogicProgrammingBridge.registerStepLocation(" + extID + "," + parentID + ")"); 
    130130                        int stepID = convertStepID(extID); 
    131131                        KahinaRunner.processEvent(new KahinaTreeEvent(KahinaTreeEventType.NEW_NODE, stepID, convertStepID(parentID))); 
    132132                        currentID = stepID; 
    133                         if (verbose
     133                        if (VERBOSE
    134134                        { 
    135135                                System.err.println("Bridge state: " + bridgeState); 
     
    150150                try 
    151151                { 
    152                         if (verbose
     152                        if (VERBOSE
    153153                                System.err.println("LogicProgrammingBridge.registerStepRedo(" + extID + ")"); 
    154154                        int lastStepID = convertStepID(extID); 
     
    178178                try 
    179179                { 
    180                         if (verbose
     180                        if (VERBOSE
    181181                                System.err.println("LogicProgrammingBridge.registerStepExit(" + extID + "," + deterministic + ")"); 
    182182                        int stepID = convertStepID(extID); 
     
    212212                try 
    213213                { 
    214                         if (verbose
     214                        if (VERBOSE
    215215                                System.err.println("LogicProgrammingBridge.registerStepFailure(" + extID + ")"); 
    216216                        int stepID = convertStepID(extID); 
     
    231231        public LogicProgrammingStep generateStep() 
    232232        { 
    233                 if (verbose
     233                if (VERBOSE
    234234                        System.err.println("LogicProgrammingBridge.generateStep()"); 
    235235                return new LogicProgrammingStep(); 
     
    242242                        if (skipFlag) 
    243243                        { 
    244                                 if (verbose
     244                                if (VERBOSE
    245245                                { 
    246246                                        System.err.println("Bridge state/pressed button: " + bridgeState + "/s"); 
     
    253253                                case 'n': 
    254254                                { 
    255                                         if (verbose
     255                                        if (VERBOSE
    256256                                        { 
    257257                                                // System.err.println("Bridge state/pressed button: n/n"); 
     
    261261                                case 'p': 
    262262                                { 
    263                                         if (verbose
     263                                        if (VERBOSE
    264264                                        { 
    265265                                                System.err.println("Bridge state/pressed button: p/n"); 
     
    269269                                case 'q': 
    270270                                { 
    271                                         if (verbose
     271                                        if (VERBOSE
    272272                                        { 
    273273                                                System.err.println("Bridge state/pressed button: q/n"); 
     
    277277                                case 'c': 
    278278                                { 
    279                                         if (verbose
     279                                        if (VERBOSE
    280280                                        { 
    281281                                                System.err.println("Bridge state/pressed button: c/c"); 
     
    286286                                case 'f': 
    287287                                { 
    288                                         if (verbose
     288                                        if (VERBOSE
    289289                                        { 
    290290                                                System.err.println("Bridge state/pressed button: f/f"); 
     
    295295                                case 'l': 
    296296                                { 
    297                                         if (verbose
     297                                        if (VERBOSE
    298298                                        { 
    299299                                                System.err.println("Bridge state/pressed button: l/c"); 
     
    304304                                case 't': 
    305305                                { 
    306                                         if (verbose
     306                                        if (VERBOSE
    307307                                        { 
    308308                                                System.err.println("Bridge state/pressed button: t/c"); 
     
    315315                                        if (skipID == currentID) 
    316316                                        { 
    317                                                 if (verbose
     317                                                if (VERBOSE
    318318                                                { 
    319319                                                        System.err.println("Bridge state/pressed button: s/n"); 
     
    325325                                        } else 
    326326                                        { 
    327                                                 if (verbose
     327                                                if (VERBOSE
    328328                                                { 
    329329                                                        System.err.println("Bridge state/pressed button: s/c"); 
     
    334334                                case 'a': 
    335335                                { 
    336                                         if (verbose
     336                                        if (VERBOSE
    337337                                        { 
    338338                                                System.err.println("Bridge state/pressed button: a/a"); 
     
    342342                                default: 
    343343                                { 
    344                                         if (verbose
     344                                        if (VERBOSE
    345345                                        { 
    346346                                                System.err.println("Bridge state/pressed button: " + bridgeState + "/n"); 
  • kahina/trunk/src/org/kahina/tralesld/bridge/TraleSLDBridge.java

    r392 r396  
    3232public class TraleSLDBridge extends LogicProgrammingBridge 
    3333{ 
    34         public static final boolean verbose = false; 
     34        public static final boolean VERBOSE = false; 
    3535 
    3636        private static final Pattern NOW_PATTERN = Pattern.compile("now\\((\\d+)\\)"); 
     
    6464                try 
    6565                { 
    66                         if (verbose
     66                        if (VERBOSE
    6767                                System.err.println("TraleSLDBridgeinitializeParseTrace(\"" + parsedSentenceList + "\")"); 
    6868                        List<String> wordList = PrologUtilities.parsePrologStringList(parsedSentenceList); 
     
    9797                try 
    9898                { 
    99                         if (verbose
     99                        if (VERBOSE
    100100                        { 
    101101                                System.err.println(this + ".registerStepInformation(" + extID + "," + nodeLabel + "," + consoleMessage + ")"); 
     
    106106                                state.linkEdgeToNode(lastRegisteredChartEdge, currentID); 
    107107                        } 
    108                         if (verbose
     108                        if (VERBOSE
    109109                        { 
    110110                                System.err.println("Matching..."); 
     
    121121                                 */ 
    122122                        } 
    123                         if (verbose
     123                        if (VERBOSE
    124124                        { 
    125125                                System.err.println("Done matching."); 
    126126                        } 
    127                         if (verbose
     127                        if (VERBOSE
    128128                        { 
    129129                                System.err.println("//" + this + ".registerStepInformation(" + extID + "," + nodeLabel + "," + consoleMessage + ")"); 
     
    149149                try 
    150150                { 
    151                         if (verbose
     151                        if (VERBOSE
    152152                        { 
    153153                                System.err.println(this + ".registerProspectiveEdge(" + ruleApplicationExtID + "," + ruleName + "," + leftmostDaughter); 
     
    164164                        state.linkEdgeToNode(newEdgeID, stepIDConv.get(ruleApplicationExtID)); 
    165165                        KahinaRunner.processEvent(new KahinaChartUpdateEvent(newEdgeID)); 
    166                         if (verbose
     166                        if (VERBOSE
    167167                        { 
    168168                                System.err.println("//" + this + ".registerProspectiveEdge(" + ruleApplicationExtID + "," + ruleName + "," + leftmostDaughter); 
     
    179179                try 
    180180                { 
    181                         if (verbose
     181                        if (VERBOSE
    182182                        { 
    183183                                System.err.println(this + "registerEdgeRetrieval(" + daughterID + ")"); 
     
    188188                        if (!chart.getDaughterEdgesForEdge(mother).contains(daughter)) 
    189189                        { 
    190                                 if (verbose
     190                                if (VERBOSE
    191191                                { 
    192192                                        System.err.println("Setting right bound for " + mother + " to that of" + daughter); 
     
    197197                        // lastRegisteredChartEdge = mother; 
    198198                        KahinaRunner.processEvent(new KahinaChartUpdateEvent(mother)); 
    199                         if (verbose
     199                        if (VERBOSE
    200200                        { 
    201201                                System.err.println("//" + this + ".registerEdgeRetrieval(" + daughterID + ")"); 
     
    212212                try 
    213213                { 
    214                         if (verbose
     214                        if (VERBOSE
    215215                        { 
    216216                                System.err.println("TraleSLDBridge.registerRuleApplication(" + extID + ",\"" + ruleName + "," + leftmostDaughter + "\")"); 
     
    222222                        stepIDConv.put(extID, newStepID); 
    223223                        registerProspectiveEdge(extID, ruleName, leftmostDaughter); 
    224                         if (verbose
     224                        if (VERBOSE
    225225                        { 
    226226                                System.err.println("Storing new step."); 
    227227                        } 
    228228                        KahinaRunner.store(newStepID, newStep); 
    229                         if (verbose
     229                        if (VERBOSE
    230230                        { 
    231231                                System.err.println("Firing rule application event."); 
     
    233233                        // let TraleSLDTreeBehavior do the rest 
    234234                        KahinaRunner.processEvent(new TraleSLDBridgeEvent(TraleSLDBridgeEventType.RULE_APP, newStepID, ruleName, extID)); 
    235                         if (verbose
     235                        if (VERBOSE
    236236                        { 
    237237                                System.err.println("Creating console message."); 
     
    239239                        // experimental: message for console 
    240240                        state.consoleMessage(newStepID, extID, LogicProgrammingStepType.CALL, consoleMessage); 
    241                         if (verbose
     241                        if (VERBOSE
    242242                        { 
    243243                                System.err.println("Firing selection event."); 
     
    251251                        // be superfluous 
    252252                        // lastEdge = currentEdge; 
    253                         if (verbose
     253                        if (VERBOSE
    254254                        { 
    255255                                System.err.println("//TraleSLDBridge.registerRuleApplication(" + extID + ",\"" + ruleName + "," + leftmostDaughter + "\")"); 
     
    266266                try 
    267267                { 
    268                         if (verbose
     268                        if (VERBOSE
    269269                        { 
    270270                                System.err.println("TraleSLDBridge.registerChartEdge(" + externalEdgeID + "," + left + "," + right + ",\"" + ruleName + "\")"); 
    271271                        } 
    272272                        int internalEdgeID = state.getChart().addEdge(left, right, ruleName, TraleSLDChartEdgeStatus.SUCCESSFUL); 
    273                         if (verbose
     273                        if (VERBOSE
    274274                                System.err.println("Internal edge ID: " + internalEdgeID); 
    275275                        edgeIDConv.put(externalEdgeID, internalEdgeID); 
    276276                        lastRegisteredChartEdge = internalEdgeID; 
    277277                        KahinaRunner.processEvent(new KahinaChartUpdateEvent(internalEdgeID)); 
    278                         if (verbose
     278                        if (VERBOSE
    279279                        { 
    280280                                System.err.println("//TraleSLDBridge.registerChartEdge(" + externalEdgeID + "," + left + "," + right + ",\"" + ruleName + "\")"); 
     
    291291                try 
    292292                { 
    293                         if (verbose
     293                        if (VERBOSE
    294294                        { 
    295295                                System.err.println("TraleSLDBridge.registerEdgeDependency(" + motherID + "," + daughterID + ")"); 
     
    371371                try 
    372372                { 
    373                         if (verbose
     373                        if (VERBOSE
    374374                                System.err.println("registerParseEnd()"); 
    375375                        bridgeState = 'n'; 
     
    390390                try 
    391391                { 
    392                         if (verbose
     392                        if (VERBOSE
    393393                        { 
    394394                                System.err.println("registerStepFailure(" + externalStepID + ")"); 
     
    400400                                int currentEdge = prospectiveEdgeStack.remove(0); 
    401401                                prospectiveEdgeCanFail = false; 
    402                                 if (verbose
     402                                if (VERBOSE
    403403                                { 
    404404                                        System.err.println("Prospective edge " + currentEdge + " failed."); 
     
    414414                        } 
    415415                        currentID = stepID; 
    416                         if (verbose
     416                        if (VERBOSE
    417417                        { 
    418418                                System.err.println("Bridge state after chart edge was marked as failed: " + bridgeState); 
     
    433433                try 
    434434                { 
    435                         if (verbose
     435                        if (VERBOSE
    436436                        { 
    437437                                System.err.println("LogicProgrammingBridge.registerStepFailure(" + extID + ")");