Search in sources :

Example 1 with AbstractTask

use of com.scythe.instrumenter.analysis.task.AbstractTask in project kanonizo by kanonizo.

the class AbstractSearchAlgorithm method start.

@Override
public void start() {
    startTime = System.currentTimeMillis();
    Task timerTask = new AbstractTask() {

        @Override
        public String asString() {
            return "Running " + getClass().getSimpleName();
        }
    };
    if (InstrumentationProperties.LOG) {
        TaskTimer.taskStart(timerTask);
    }
    fw.getDisplay().notifyTaskStart("Running Test Prioritisation", false);
    generateSolution();
    TaskTimer.taskEnd(timerTask);
    BufferedOutputStream stream = null;
    try {
        File file = new File(InstrumentationProperties.LOG_DIR + "/algorithm_time.dat");
        File logdir = new File(InstrumentationProperties.LOG_DIR);
        if (!logdir.exists()) {
            logdir.mkdirs();
        }
        if (!file.exists()) {
            file.createNewFile();
        }
        stream = new BufferedOutputStream(new FileOutputStream(file));
        stream.write(String.valueOf(System.currentTimeMillis() - startTime).getBytes());
    } catch (final IOException e) {
        e.printStackTrace();
    } finally {
        totalTime = System.currentTimeMillis() - startTime;
        if (stream != null) {
            try {
                stream.close();
            } catch (final IOException e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : Task(com.scythe.instrumenter.analysis.task.Task) AbstractTask(com.scythe.instrumenter.analysis.task.AbstractTask) AbstractTask(com.scythe.instrumenter.analysis.task.AbstractTask) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) BufferedOutputStream(java.io.BufferedOutputStream) File(java.io.File)

Aggregations

AbstractTask (com.scythe.instrumenter.analysis.task.AbstractTask)1 Task (com.scythe.instrumenter.analysis.task.Task)1 BufferedOutputStream (java.io.BufferedOutputStream)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1