From dbca39747187eb7dc2cf1c74fbdf5f2fc937a90f Mon Sep 17 00:00:00 2001 From: Tom Copeland Date: Mon, 24 Mar 2003 21:36:07 +0000 Subject: [PATCH] Minor refactoring git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@1606 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd/src/net/sourceforge/pmd/cpd/CPD.java | 28 ++++++++---------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/pmd/src/net/sourceforge/pmd/cpd/CPD.java b/pmd/src/net/sourceforge/pmd/cpd/CPD.java index 567675e9c0..98470bad36 100644 --- a/pmd/src/net/sourceforge/pmd/cpd/CPD.java +++ b/pmd/src/net/sourceforge/pmd/cpd/CPD.java @@ -48,12 +48,12 @@ public class CPD { } public void go() { - if (!listener.update("Starting to process " + tokenSets.size() + " files")) + if (!listener.update("Starting to process " + tokenSets.size() + " files; " + tokenSets.tokenCount() + " tokens")) return; GST gst = new GST(tokenSets, minimumTileSize); results = gst.crunch(listener); if (results == null) - results = new ResultsImpl(); //just ot make sure we don't pass back a null Results + results = new ResultsImpl(); //just to make sure we don't pass back a null Results } public Results getResults() { @@ -107,28 +107,18 @@ public class CPD { } CPD cpd = new CPD(); cpd.setListener(new CPDNullListener()); - - try { - cpd.setMinimumTileSize(Integer.parseInt(args[0])); - } catch (Exception e) { - usage(); - System.exit(1); - } + cpd.setMinimumTileSize(Integer.parseInt(args[0])); try { cpd.addRecursively(args[1]); + long start = System.currentTimeMillis(); + cpd.go(); + long total = System.currentTimeMillis() - start; + System.out.println("Time elapsed in milliseconds: " + total); + System.out.println((new TextRenderer()).render(cpd)); } catch (Exception e) { - e.printStackTrace(); - System.exit(1); + usage(); } - - long start = System.currentTimeMillis(); - cpd.go(); - long total = System.currentTimeMillis() - start; - System.out.println("That took " + total); - CPDRenderer renderer = new TextRenderer(); - System.out.println(renderer.render(cpd)); - System.out.println("That took " + total); } private static void usage() {