Example usage for com.google.common.base Stopwatch stop

List of usage examples for com.google.common.base Stopwatch stop

Introduction

In this page you can find the example usage for com.google.common.base Stopwatch stop.

Prototype

public Stopwatch stop() 

Source Link

Document

Stops the stopwatch.

Usage

From source file:com.hortonworks.streamline.common.util.ParallelStreamUtil.java

public static void runAsync(Callable<Void> callable, Executor executor) {
    Stopwatch stopwatch = Stopwatch.createStarted();
    LOG.debug("runAsync start");
    CompletableFuture<Void> res = CompletableFuture.supplyAsync(() -> {
        try {/*from  ww w. j  av  a 2 s  .c  o m*/
            return callable.call();
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }, executor);

    res.whenComplete((r, th) -> {
        // LOG any exceptions
        if (th != null) {
            LOG.error("Got exception while running async task", th.getCause());
        }
        LOG.debug("runAsync complete - elapsed: {} ms", stopwatch.elapsed(TimeUnit.MILLISECONDS));
        stopwatch.stop();
    });
}

From source file:de.nx42.maps4cim.MapGenerator.java

/**
 * Launches the map generator using the specified configuration
 * and writes the resulting map to the specified file.
 *
 * Returns true, iff the map was generated without errors.
 *
 * @param conf the map is generated based on the information provided in
 *             this config/*from   w  w  w  .  j av a2  s . co  m*/
 * @param dest the file where the resulting map is written to
 * @return true, iff the map was generated without errors
 */
public static boolean execute(Config conf, File dest) {
    try {
        final Stopwatch stopwatch = Stopwatch.createStarted();
        log.info("Map Generator has been started.");
        MapGenerator mg = new MapGenerator(conf);

        try {
            log.debug("Ressources initialized. The map will now be written...");
            Result res = mg.generateMap(dest);

            stopwatch.stop();
            if (res.isSuccess()) {
                log.info("The map has been successfully generated. Total Time: {}", stopwatch.toString());
                logAttribution(conf);
                return true;
            } else {
                log.warn(res.getReport());
                log.warn("Something went wrong, so your map has been generated "
                        + "in fallback mode (probably it's just empty).\n"
                        + "Please review the errors and post this log in the "
                        + "forums if you are not sure how to fix them.");
                return false;
            }
        } catch (MapGeneratorException e) {
            // errors are already logged
            return false;
        }
    } catch (Exception e) {
        log.error("Unexpected Exception", e);
        return false;
    }
}

From source file:info_teorija_1.Encode.java

public static void encode(int wordLength, File in, File out) throws IOException {
    Stopwatch total = Stopwatch.createStarted();
    Stopwatch time = Stopwatch.createStarted();

    /* create input/output buffered file streams */
    FileInputStream inputStream = new FileInputStream(in);
    BufferedInputStream src = new BufferedInputStream(inputStream);
    input = new BitInput(src);

    OutputStream dst = new FileOutputStream(out);
    BufferedOutputStream outputStream = new BufferedOutputStream(dst);
    output = new BitOutput(outputStream);

    getFrequenciesAndWriteRemainder(in, wordLength);
    System.out.println("getFrequancies " + time.elapsed(TimeUnit.MILLISECONDS));

    time.stop();
    time = Stopwatch.createStarted();/*  w  ww .j a  va 2s.  c om*/

    // build tree
    HuffmanTree tree = HuffmanCode.buildTree(byteFreqs);
    System.out.println("BuildTree " + time.elapsed(TimeUnit.MILLISECONDS));

    time.stop();
    time = Stopwatch.createStarted();

    // generateCodes and fill huffmanTable
    HuffmanCode.genCodes(tree, new StringBuffer());
    System.out.println("genCodes " + time.elapsed(TimeUnit.MILLISECONDS));

    Encode.wordLength = wordLength;

    time.stop();
    time = Stopwatch.createStarted();

    output.writeUnsignedInt(4, wordLength - 1);
    output.writeUnsignedLong(32, bytesLength);

    encodeTree(tree);
    System.out.println("encodeTree " + time.elapsed(TimeUnit.MILLISECONDS));
    time.stop();
    time = Stopwatch.createStarted();

    encodeFile();

    System.out.println("encodeFile " + time.elapsed(TimeUnit.MILLISECONDS));
    time.stop();

    outputStream.close();
    inputStream.close();
    System.out.println("TOTAL: " + total.elapsed(TimeUnit.MILLISECONDS));
    total.stop();
}

From source file:com.springer.omelet.driver.DriverUtility.java

/***
 * Generic waitFor Function which waits for condition to be successful else
 * return null/*from  ww  w  . j  a va 2 s . co m*/
 * 
 * @param expectedCondition
 *            :ExpectedCondition<T>
 * @param driver
 *            :WebDriver
 * @param timeout
 *            in seconds
 * @return <T> or null
 */
public static <T> T waitFor(ExpectedCondition<T> expectedCondition, WebDriver driver, int timeOutInSeconds) {
    Stopwatch stopwatch = new Stopwatch();
    stopwatch.start();
    driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS);
    try {
        T returnValue = new WebDriverWait(driver, timeOutInSeconds).pollingEvery(500, TimeUnit.MILLISECONDS)
                .until(expectedCondition);
        return returnValue;
    } catch (TimeoutException e) {
        LOGGER.error(e);
        return null;
    } finally {
        driver.manage().timeouts().implicitlyWait(Driver.getBrowserConf().getDriverTimeOut(), TimeUnit.SECONDS);
        stopwatch.stop();
        LOGGER.debug("Time Taken for waitFor method for Expected Condition is:"
                + stopwatch.elapsedTime(TimeUnit.SECONDS));
    }
}

From source file:matching.naive.BranchAndBoundMatching.java

/**
 * Tiny tests / benchmarks./*  w ww  .java 2  s  .  c o m*/
 */
public static void _main(final String[] args) {

    /*
    final double[][] matrix =
    {
        { 0, 1, 2, 3 },
        { 1, 0, 10, 20 },
        { 2, 10, 0, 10 },
        { 3, 20, 10, 0 },
    };
    */

    final double[][] matrix = {
            //     A  B  C  D
            /*A*/{ 0, 1, 5, 10 }, /*B*/{ 1, 0, 1, 1 }, /*C*/{ 5, 1, 0, 1 }, /*D*/{ 10, 1, 1, 0 } };
    // TODO ? normaliser la matrice entre 0 et 1 ?
    /*
    final double[][] matrix =
    {
        { 0, 1, 1, 1, 1, 1 },
        { 1, 0, 1, 1, 1, 1 },
        { 1, 1, 0, 1, 1, 1 },
        { 1, 1, 1, 0, 1, 1 },
        { 1, 1, 1, 1, 0, 1 },
        { 1, 1, 1, 1, 1, 0 },
    };
    */

    /*
    final double[][] matrix =
    {
        { 0, 10, 1, 1, 1, 1, 1, 1 },
        { 10, 0, 1, 1, 1, 1, 1, 1 },
        { 1, 1, 0, 1, 1, 1, 1, 1 },
        { 1, 1, 1, 0, 1, 1, 1, 1 },
        { 1, 1, 1, 1, 0, 1, 1, 1 },
        { 1, 1, 1, 1, 1, 0, 1, 1 },
        { 1, 1, 1, 1, 1, 1, 0, 1 },
        { 1, 1, 1, 1, 1, 1, 1, 0 },
    };
    */

    final BranchAndBoundMatching matching = new BranchAndBoundMatching(matrix);
    final List<String> labels = Lists.newArrayList("A", "B", "C", "D", "E", "F");

    final Function<Position, String> mapping = new Function<Position, String>() {

        @Override
        public String apply(final Position position) {
            return labels.get(position.getRowIndex()) + labels.get(position.getColumnIndex());
        }

    };

    final Stopwatch stopwatch = new Stopwatch();

    stopwatch.start();
    //final Match firstMatch = matching.match(Extremum.MIN);
    //System.out.println(firstMatch);
    //System.out.println(firstMatch.apply(mapping));
    final Iterable<Match> matches = matching.matchAll();
    stopwatch.stop();
    for (final Match match : matches)
        System.out.println(match.apply(mapping));
    System.out.println(stopwatch.elapsedTime(TimeUnit.NANOSECONDS) + " " + TimeUnit.NANOSECONDS.toString());

}

From source file:org.apache.jackrabbit.oak.plugins.backup.FileStoreBackup.java

public static void backup(NodeStore store, File destination) throws IOException {
    checkArgument(store instanceof SegmentNodeStore);
    Stopwatch watch = Stopwatch.createStarted();
    NodeState current = ((SegmentNodeStore) store).getSuperRoot();
    FileStore.Builder builder = FileStore.builder(destination).withDefaultMemoryMapping();
    if (USE_FAKE_BLOBSTORE) {
        builder.withBlobStore(new BasicReadOnlyBlobStore());
    }//from  www .ja  v a 2s. com
    FileStore backup = builder.build();
    try {
        SegmentNodeState state = backup.getHead();
        Compactor compactor = new Compactor(backup.getTracker());
        compactor.setDeepCheckLargeBinaries(true);
        compactor.setContentEqualityCheck(true);
        SegmentNodeState after = compactor.compact(state, current, state);
        backup.setHead(state, after);
    } finally {
        backup.close();
    }
    watch.stop();
    log.info("Backup finished in {}.", watch);
}

From source file:org.apache.brooklyn.test.performance.PerformanceMeasurer.java

/**
 * Runs a performance test. Repeatedly executes the given job. It measuring either the time it takes for
 * many iterations, or the number of iterations it can execute in a fixed time.
 *///from   www  . j av a2s .co  m
public static PerformanceTestResult run(PerformanceTestDescriptor options) {
    options.seal();
    long nextLogTime = (options.logInterval == null) ? Long.MAX_VALUE : options.logInterval.toMilliseconds();

    // Try to force garbage collection before the test, so it interferes less with the measurement.
    System.gc();
    System.gc();

    // Run some warm-up cycles.
    Stopwatch warmupWatch = Stopwatch.createStarted();
    int warmupCounter = 0;

    while ((options.warmup != null) ? options.warmup.isLongerThan(warmupWatch)
            : warmupCounter < options.warmupIterations) {
        if (warmupWatch.elapsed(TimeUnit.MILLISECONDS) >= nextLogTime) {
            LOG.info("Warm-up " + options.summary + " iteration=" + warmupCounter + " at "
                    + Time.makeTimeStringRounded(warmupWatch));
            nextLogTime += options.logInterval.toMilliseconds();
        }
        options.job.run();
        warmupCounter++;
    }
    warmupWatch.stop();

    // Run the actual test (for the given duration / iterations); then wait for completionLatch (if supplied).
    nextLogTime = (options.logInterval == null) ? Long.MAX_VALUE : options.logInterval.toMilliseconds();
    int counter = 0;
    Histogram histogram = new Histogram();
    List<Double> cpuSampleFractions = Lists.newLinkedList();
    Future<?> sampleCpuFuture = null;
    if (options.sampleCpuInterval != null) {
        sampleCpuFuture = PerformanceTestUtils.sampleProcessCpuTime(options.sampleCpuInterval, options.summary,
                cpuSampleFractions);
    }

    try {
        long preCpuTime = PerformanceTestUtils.getProcessCpuTime();
        Stopwatch watch = Stopwatch.createStarted();

        while ((options.duration != null) ? options.duration.isLongerThan(watch)
                : counter < options.iterations) {
            if (warmupWatch.elapsed(TimeUnit.MILLISECONDS) >= nextLogTime) {
                LOG.info(
                        options.summary + " iteration=" + counter + " at " + Time.makeTimeStringRounded(watch));
                nextLogTime += options.logInterval.toMilliseconds();
            }
            long before = watch.elapsed(TimeUnit.NANOSECONDS);
            options.job.run();
            if (options.histogram) {
                histogram.add(watch.elapsed(TimeUnit.NANOSECONDS) - before, TimeUnit.NANOSECONDS);
            }
            counter++;
        }

        if (options.completionLatch != null) {
            try {
                boolean success = options.completionLatch.await(options.completionLatchTimeout.toMilliseconds(),
                        TimeUnit.MILLISECONDS);
                if (!success) {
                    fail("Timeout waiting for completionLatch: test=" + options + "; counter=" + counter);
                }
            } catch (InterruptedException e) {
                throw Exceptions.propagate(e);
            }
        }
        watch.stop();
        long postCpuTime = PerformanceTestUtils.getProcessCpuTime();

        // Generate the results
        PerformanceTestResult result = new PerformanceTestResult();
        result.warmup = Duration.of(warmupWatch);
        result.warmupIterations = warmupCounter;
        result.duration = Duration.of(watch);
        result.iterations = counter;
        result.ratePerSecond = (((double) counter) / watch.elapsed(TimeUnit.MILLISECONDS)) * 1000;
        result.cpuTotalFraction = (watch.elapsed(TimeUnit.NANOSECONDS) > 0 && preCpuTime >= 0)
                ? ((double) postCpuTime - preCpuTime) / watch.elapsed(TimeUnit.NANOSECONDS)
                : -1;
        if (options.histogram) {
            result.histogram = histogram;
        }
        if (options.sampleCpuInterval != null) {
            result.cpuSampleFractions = cpuSampleFractions;
        }
        result.minAcceptablePerSecond = options.minAcceptablePerSecond;

        // Persist the results
        if (options.persister != null) {
            options.persister.persist(new Date(), options, result);
        }

        // Fail if we didn't meet the minimum performance requirements
        if (options.minAcceptablePerSecond != null && options.minAcceptablePerSecond > result.ratePerSecond) {
            fail("Performance too low: test=" + options + "; result=" + result);
        }

        return result;

    } finally {
        if (sampleCpuFuture != null) {
            sampleCpuFuture.cancel(true);
        }
    }
}

From source file:blue.lapis.pore.event.PoreEventWrapper.java

@SuppressWarnings("unchecked")
public static void register() throws IOException {
    Stopwatch watch = Stopwatch.createStarted();

    BufferedReader reader = new BufferedReader(
            new InputStreamReader(PoreEventWrapper.class.getResourceAsStream("events.txt")));

    String line;//from w  ww  . j  av a  2 s .c o  m
    while ((line = reader.readLine()) != null) {
        line = line.trim();
        if (line.isEmpty() || line.charAt(0) == '#') {
            continue;
        }

        try {
            register((Class<? extends Event>) Class.forName(line));
        } catch (ClassNotFoundException e) {
            Pore.getLogger().warn("Failed to register class {} as an event", line, e);
        }
    }

    Pore.getLogger().debug("Registered events in {}", watch.stop());
}

From source file:info_teorija_1.Decode.java

public static void decode(File in, File out) throws IOException {
    Stopwatch total = Stopwatch.createStarted();
    Stopwatch time = Stopwatch.createStarted();

    FileInputStream src = new FileInputStream(in);
    BufferedInputStream inputStream = new BufferedInputStream(src);
    input = new BitInput(inputStream);

    FileOutputStream dst = new FileOutputStream(out);
    BufferedOutputStream outputStream = new BufferedOutputStream(dst);
    output = new BitOutput(outputStream);

    int remainderLength = input.readUnsignedInt(4);
    int remainder = 0;

    if (remainderLength != 0) {
        remainder = input.readUnsignedInt(15);
    } else {//from w  w  w . j  ava  2s.  com
        input.readUnsignedInt(15);
    }

    wordLength = input.readUnsignedInt(4) + 1;
    length = input.readUnsignedLong(32);

    System.out.println("setup() " + time.elapsed(TimeUnit.MILLISECONDS));
    time.stop();
    time = Stopwatch.createStarted();

    while (true) {
        if (totalHuffmanLeafs != 0 && totalHuffmanLeafs == currentHuffmanLeafs) {
            break;
        }
        decodeTree();
    }
    System.out.println("decodeTree() " + time.elapsed(TimeUnit.MILLISECONDS));

    time.stop();
    time = Stopwatch.createStarted();

    HuffmanCode.genCodes(tree, new StringBuffer());
    System.out.println("genCodes() " + time.elapsed(TimeUnit.MILLISECONDS));

    time.stop();
    time = Stopwatch.createStarted();

    decodeFile();
    System.out.println("decodeFile() " + time.elapsed(TimeUnit.MILLISECONDS));
    if (remainderLength != 0)
        output.writeUnsignedInt(remainderLength, remainder);

    inputStream.close();
    outputStream.close();
    System.out.println("total: " + total.elapsed(TimeUnit.MILLISECONDS));

}

From source file:org.apache.tez.log.LogParser.java

public static void main(String[] args) throws IOException {
    Preconditions.checkArgument(args.length == 1, "Please provide the file to be parsed");
    File inputFile = new File(args[0]);
    Preconditions.checkArgument(inputFile.exists(),
            "Please provide valid file. " + inputFile + " does not exist");

    Stopwatch sw = Stopwatch.createStarted();

    LogParser parser = new LogParser(inputFile);

    parser.process();/*from   ww  w .  ja v a2  s.c o  m*/
    System.out.println();

    IAnalyzer vertexMappingAnalyzer = parser.getAnalyzers().get(VertexMappingAnalyzer.class.getName());
    IAnalyzer vertexFinishedAnalyzer = parser.getAnalyzers().get(VertexFinishedAnalyzer.class.getName());
    if (vertexMappingAnalyzer != null && vertexFinishedAnalyzer != null) {
        System.out.println("Vertices that haven't finished");
        System.out.println("*******************************");
        Map<String, String> vertexMapping = (Map<String, String>) vertexMappingAnalyzer.getResult();
        Map<VertexFinishedAnalyzer.VertexFinished, String> vertexFinishedMap = (Map<VertexFinishedAnalyzer.VertexFinished, String>) vertexFinishedAnalyzer
                .getResult();

        for (Map.Entry<String, String> e : vertexMapping.entrySet()) {
            boolean found = false;
            for (Map.Entry<VertexFinishedAnalyzer.VertexFinished, String> fe : vertexFinishedMap.entrySet()) {
                if (fe.getKey().vertexId.equalsIgnoreCase(e.getKey())) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                System.out.println(e.getKey() + " is not in finished map list. " + e.getValue());
            }
        }
    }

    /**
     * In case shuffle-blamed-for details is there, co-relate with rack details
     */
    IAnalyzer shuffleBlamedFor = parser.getAnalyzers().get(ShuffleBlamedForAnalyzer.class.getName());
    IAnalyzer rackResolver = parser.getAnalyzers().get(RackResolverExtractor.class.getName());
    if (shuffleBlamedFor != null && rackResolver != null) {
        // machine --> rack mapping
        Map<String, String> rackMap = (Map<String, String>) rackResolver.getResult();

        ShuffleBlamedForAnalyzer.ShuffleBlamedForResult result = (ShuffleBlamedForAnalyzer.ShuffleBlamedForResult) shuffleBlamedFor
                .getResult();

        parser.addAdditionalAnalysis("Source machine details..", true);
        for (String srcMachine : result.getSrcMachines()) {
            //machine:45454, containerPriority= 8, containerResources=<memory:3584, vCores:1>
            String machine = srcMachine.substring(0, srcMachine.indexOf(":"));
            parser.addAdditionalAnalysis(machine + " --> " + rackMap.get(machine));
        }

        parser.addAdditionalAnalysis("");
        parser.addAdditionalAnalysis("");
        parser.addAdditionalAnalysis("Fetcher machine details..", true);
        for (String fetcherMachine : result.getFetcherMachines()) {
            //machine:45454, containerPriority= 8, containerResources=<memory:3584, vCores:1>
            String machine = fetcherMachine.substring(0, fetcherMachine.indexOf(":"));
            parser.addAdditionalAnalysis(machine + " --> " + rackMap.get(machine));
        }
    }

    /**
     * For containers timeouts. Relate ContainerTimeoutAnalyzer and NodesAnalyzer
     *
     */
    IAnalyzer containerTimeoutAnalyzer = parser.getAnalyzers().get(ContainerTimeoutAnalyzer.class.getName());
    IAnalyzer nodesAnalyzer = parser.getAnalyzers().get(NodesAnalyzer.class.getName());
    if (nodesAnalyzer != null && containerTimeoutAnalyzer != null) {
        List<String> containersWithTimeout = (List<String>) containerTimeoutAnalyzer.getResult();

        // Node --> <attempt, container>
        Map<String, Map<String, String>> nodesResult = (Map<String, Map<String, String>>) nodesAnalyzer
                .getResult();

        parser.addAdditionalAnalysis("");
        parser.addAdditionalAnalysis("Container time outs and attempt/node details", true);
        for (String container : containersWithTimeout) {
            for (Map.Entry<String, Map<String, String>> nodeEntry : nodesResult.entrySet()) {
                Map<String, String> attemptToContainer = nodeEntry.getValue();
                for (Map.Entry<String, String> attemptEntry : attemptToContainer.entrySet()) {
                    if (attemptEntry.getValue().equalsIgnoreCase(container)) {
                        parser.addAdditionalAnalysis(
                                container + " --> " + nodeEntry.getKey() + " --> " + attemptEntry.getKey());
                    }
                }
            }
        }
        parser.addAdditionalAnalysis("");
    }

    /**
     * Task attempts not finished
     */
    IAnalyzer taskAttemptStarted = parser.getAnalyzers().get(TaskAttemptStartedAnalyzer.class.getName());
    IAnalyzer taskAttemptFinished = parser.getAnalyzers().get(TaskAttemptFinishedAnalyzer.class.getName());
    if (taskAttemptFinished != null && taskAttemptStarted != null) {
        Map<String, TaskAttemptStartedAnalyzer.TaskAttemptStarted> started = (Map<String, TaskAttemptStartedAnalyzer.TaskAttemptStarted>) taskAttemptStarted
                .getResult();
        Map<String, TaskAttemptFinishedAnalyzer.TaskAttemptFinished> finished = (Map<String, TaskAttemptFinishedAnalyzer.TaskAttemptFinished>) taskAttemptFinished
                .getResult();

        parser.addAdditionalAnalysis(
                "List of unfinished tasks!! started=" + started.size() + ", " + "finished=" + finished.size(),
                true);
        for (String task : started.keySet()) {
            //check if this task is in finished keys
            if (!finished.keySet().contains(task)) {
                parser.addAdditionalAnalysis(task + " is not in finished list");
            }
        }
    }

    /**
     * For swimlanes (not including killed tasks)
     */
    /*
    TODO: Need to work on this.
            
            
    IAnalyzer nodeAnalyzer = parser.getAnalyzers()
        .get(NodesAnalyzer.class.getName());
    IAnalyzer taFinishedAnalyzer = parser.getAnalyzers()
        .get(TaskAttemptFinishedAnalyzer.class.getName());
    if (nodeAnalyzer != null && taFinishedAnalyzer != null) {
      // machine --> task --> container
      Map<String, Map<String, String>> nodes =
          (Map<String, Map<String, String>>) nodeAnalyzer.getResult();
      // taskIDStr --> taskAttemptFinished
      Map<String, TaskAttemptFinishedAnalyzer.TaskAttemptFinished> taFinishedMap =
          (Map<String, TaskAttemptFinishedAnalyzer.TaskAttemptFinished>)
      taFinishedAnalyzer.getResult();
            
      //Dirty hack to get all DAG
      Set<String> allDags = Sets.newHashSet();
      for(Map.Entry<String, Map<String, String>> entry : nodes.entrySet()) {
        for (Map.Entry<String, String> taskEntry : entry.getValue().entrySet()) {
          String taskId = taskEntry.getKey();
          //attempt_1478350923850_0006_7
          allDags.add(taskId.substring(0, 28));
        }
      }
            
      // Construct a map of machine_container --> List<TaskAttemptId> from analyzer dataset.
      final Map<String, TreeSet<TaskAttemptFinishedAnalyzer.TaskAttemptFinished>> mapping = Maps.newHashMap();
      long minTime = Long.MAX_VALUE;
      long maxTime = Long.MIN_VALUE;
      for(String dag : allDags) {
        for (Map.Entry<String, Map<String, String>> entry : nodes.entrySet()) {
          for (Map.Entry<String, String> taskEntry : entry.getValue().entrySet()) {
    String machine = entry.getKey();
            
    String taskId = taskEntry.getKey();
    String containerId = taskEntry.getValue();
            
    if (!taskId.contains("1478350923850_0006_9")) {
      continue;
    }
            
    String machineContainer = machine + "_" + containerId;
    TreeSet<TaskAttemptFinishedAnalyzer.TaskAttemptFinished> attempts = mapping.get
        (machineContainer);
            
    if (attempts == null) {
      attempts = new TreeSet<>(
          new Comparator<TaskAttemptFinishedAnalyzer.TaskAttemptFinished>() {
            @Override public int compare(TaskAttemptFinishedAnalyzer.TaskAttemptFinished o1,
                TaskAttemptFinishedAnalyzer.TaskAttemptFinished o2) {
              if (Long.parseLong(o1.startTime) < Long.parseLong(o2.startTime)) {
                return -1;
              } else if (Long.parseLong(o1.startTime) > Long.parseLong(o2.startTime)) {
                return 1;
              } else {
                return 0;
              }
            }
          });
      mapping.put(machineContainer, attempts);
    }
            
    //Check if the attempt id is available in finished maps
    if (taFinishedMap.containsKey(taskId)) {
      TaskAttemptFinishedAnalyzer.TaskAttemptFinished attempt = taFinishedMap.get(taskId);
      attempts.add(attempt);
      if (Long.parseLong(attempt.finishTime) >= maxTime) {
        maxTime = Long.parseLong(attempt.finishTime);
      } else if (Long.parseLong(attempt.startTime) <= minTime) {
        minTime = Long.parseLong(attempt.startTime);
      }
    }
          }
        }
      }
            
      // draw SVG
      System.out.println("MinTime: " + minTime + ". maxTime: " + maxTime);
      SVGUtils svg = new SVGUtils(minTime, maxTime, new TreeSet(mapping.keySet()));
      int yOffset = 1;
      for(Map.Entry<String, TreeSet<TaskAttemptFinishedAnalyzer.TaskAttemptFinished>> entry :
          mapping.entrySet()) {
        for (TaskAttemptFinishedAnalyzer.TaskAttemptFinished task : entry.getValue()) {
          //draw lines
          svg.drawStep(task.vertexId, Long.parseLong(task.startTime), Long.parseLong(task
          .timeTaken), yOffset, "LightGreen");
        }
        yOffset++;
      }
            
      svg.saveFileStr("/tmp/test.svg");
      System.out.println("Wrote to /tmp/test.svg");
            
      // Now generate the swimlane.
            
            
    }
    */

    System.out.println();
    parser.writeAnalysis();

    System.out.println("Time taken " + (sw.elapsed(TimeUnit.SECONDS)) + " seconds");
    sw.stop();
}