From: <ton...@us...> - 2008-03-02 15:41:07
|
Revision: 671 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=671&view=rev Author: tonytacker Date: 2008-03-02 07:40:29 -0800 (Sun, 02 Mar 2008) Log Message: ----------- some statistics for algorithm Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java trunk/src/dl-learner/org/dllearner/gui/RunPanel.java trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-29 10:56:30 UTC (rev 670) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-03-02 15:40:29 UTC (rev 671) @@ -48,6 +48,9 @@ private LearningAlgorithm la; private LearningAlgorithm oldLearningAlgorithm; private boolean[] isInit = new boolean[4]; + private Boolean threadIsRunning = false; + private Long algorithmRunStartTime = null; + private Long algorithmRunStopTime = null; /** * Get ComponentManager. @@ -274,4 +277,38 @@ isInit[3] = is; } + /** + * Set true if you start the algorithm. + * + * @param isThreadRunning + */ + public void setThreadIsRunning(Boolean isThreadRunning) { + if (isThreadRunning) + algorithmRunStartTime = System.nanoTime(); + else if (algorithmRunStartTime != null) + if (algorithmRunStartTime < System.nanoTime()) + algorithmRunStopTime = System.nanoTime(); + this.threadIsRunning = isThreadRunning; + } + + /** + * Get true if algorithm has started, false if not. + * + * @return true if algorithm is running, false if not. + */ + public Boolean getThreadIsRunning() { + return this.threadIsRunning; + } + + /** + * Get time in ns for run of algorithm. + * + * @return time in ns + */ + public Long getAlgorithmRunTime() { + if (algorithmRunStartTime != null && algorithmRunStopTime != null) + if (algorithmRunStartTime < algorithmRunStopTime) + return algorithmRunStopTime - algorithmRunStartTime; + return null; + } } Modified: trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java 2008-02-29 10:56:30 UTC (rev 670) +++ trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java 2008-03-02 15:40:29 UTC (rev 671) @@ -34,7 +34,7 @@ import java.io.PrintWriter; /** - * Open a config file. + * Save a config file. * * @author Tilo Hielscher */ Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-02-29 10:56:30 UTC (rev 670) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-02 15:40:29 UTC (rev 671) @@ -25,6 +25,7 @@ import java.awt.event.ActionListener; import javax.swing.*; +import java.lang.Long; /** * RunPanel let algorithm start and stop and show informations about. @@ -36,7 +37,8 @@ private static final long serialVersionUID = 1643304576470046636L; - private JButton runButton, stopButton, getBestSolutionButton, getSolutionScoreButton; + private JButton runButton, stopButton, getBestSolutionButton, getSolutionScoreButton, + getReasonerStatsButton; private JTextArea infoArea; private Config config; @@ -63,6 +65,9 @@ getSolutionScoreButton = new JButton("GetSolutionScore"); getSolutionScoreButton.addActionListener(this); + getReasonerStatsButton = new JButton("GetReasonerStats"); + getReasonerStatsButton.addActionListener(this); + infoArea = new JTextArea(20, 50); JScrollPane infoScroll = new JScrollPane(infoArea); @@ -73,6 +78,7 @@ solutionPanel.add(getBestSolutionButton); solutionPanel.add(getSolutionScoreButton); + solutionPanel.add(getReasonerStatsButton); add(showPanel, BorderLayout.PAGE_START); add(infoPanel, BorderLayout.CENTER); @@ -98,6 +104,58 @@ if (e.getSource() == getSolutionScoreButton && runBoolean) { infoArea.setText(config.getLearningAlgorithm().getSolutionScore().toString()); } + // ReasonerStats + if (e.getSource() == getReasonerStatsButton && runBoolean) { + infoArea.setText(""); + infoArea.append("Algorithm Runtime: " + + makeTime(config.getAlgorithmRunTime()) + "\n"); + infoArea.append("OverallReasoningTime: " + + makeTime(config.getReasoningService().getOverallReasoningTimeNs()) + "\n"); + infoArea.append("Instances (" + config.getReasoningService().getNrOfInstanceChecks() + + "): "); + if (config.getReasoningService().getNrOfInstanceChecks() > 0) + infoArea.append(makeTime(config.getReasoningService().getTimePerInstanceCheckNs()) + + "\n"); + else + infoArea.append(" - \n"); + infoArea.append("Retrieval (" + config.getReasoningService().getNrOfRetrievals() + + "): "); + if (config.getReasoningService().getNrOfRetrievals() > 0) + infoArea.append(makeTime(config.getReasoningService().getTimePerRetrievalNs()) + + "\n"); + else + infoArea.append(" - \n"); + infoArea.append("Subsumption (" + + config.getReasoningService().getNrOfSubsumptionChecks() + "): " + + makeTime(config.getReasoningService().getTimePerSubsumptionCheckNs()) + "\n"); + } } + /** + * Build a String form nanoSeconds. + * + * @param nanoSeconds + * is type of Long and represent a time interval in ns + * @return a string like this: 3h 12min 46s 753ms + */ + public String makeTime(Long nanoSeconds) { + String time = ""; + Integer hours = 0, minutes = 0, seconds = 0, miliSeconds = 0; + nanoSeconds /= 1000000; // miliSeconds + hours = Math.round(nanoSeconds / 1000 / 60 / 60); + minutes = Math.round(nanoSeconds / 1000 / 60); + seconds = Math.round(nanoSeconds / 1000); + miliSeconds = Math.round(nanoSeconds - (hours * 1000 * 60 * 60) - (minutes * 1000 * 60) + - (seconds * 1000)); + if (hours > 0) + time += hours + "h "; + if (minutes > 0) + time += minutes + "min "; + if (seconds > 0) + time += seconds + "s "; + if (miliSeconds > 0) + time += miliSeconds + "ms "; + // System.out.println("time: " + time); + return time; + } } Modified: trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java 2008-02-29 10:56:30 UTC (rev 670) +++ trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java 2008-03-02 15:40:29 UTC (rev 671) @@ -38,8 +38,11 @@ */ @Override public void run() { - if (config.getLearningAlgorithm() != null) + if (config.getLearningAlgorithm() != null) { + config.setThreadIsRunning(true); config.getLearningAlgorithm().start(); + config.setThreadIsRunning(false); + } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |