diff options
Diffstat (limited to 'src/main/java/bjc/rgens/parser/RGrammarSet.java')
| -rwxr-xr-x | src/main/java/bjc/rgens/parser/RGrammarSet.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main/java/bjc/rgens/parser/RGrammarSet.java b/src/main/java/bjc/rgens/parser/RGrammarSet.java index c797b8c..ad9836f 100755 --- a/src/main/java/bjc/rgens/parser/RGrammarSet.java +++ b/src/main/java/bjc/rgens/parser/RGrammarSet.java @@ -29,6 +29,8 @@ public class RGrammarSet { /* Contains which file a grammar was loaded from. */ private Map<String, String> loadedFrom; + public static final boolean PERF = true; + /** Create a new set of randomized grammars. */ public RGrammarSet() { grammars = new HashMap<>(); @@ -222,6 +224,8 @@ public class RGrammarSet { /* The grammar set to hand back. */ RGrammarSet set = new RGrammarSet(); + long startCFGTime = System.nanoTime(); + /* Get the directory that contains the config file. */ Path cfgParent = cfgFile.getParent(); @@ -263,12 +267,20 @@ public class RGrammarSet { } else if (convPath.getFileName().toString().endsWith(".gram")) { /* Load grammar file. */ try { + long startFileTime = System.nanoTime(); BufferedReader fis = Files.newBufferedReader(convPath); RGrammar gram = RGrammarParser.readGrammar(fis); fis.close(); + long endFileTime = System.nanoTime(); + + long fileTime = endFileTime - startFileTime; + + if(PERF) + System.err.printf("\tPERF: Read grammar %s in %d ns (%f s)\n", convPath, fileTime, fileTime / 1000000000.0); + /* Add grammar to the set. */ set.addGrammar(name, gram); @@ -288,6 +300,13 @@ public class RGrammarSet { } } + long endCFGTime = System.nanoTime(); + + long cfgDur = endCFGTime - startCFGTime; + + if(PERF) + System.err.printf("\n\nPERF: Read config file %s in %d ns (%f s)\n", cfgFile, cfgDur, cfgDur / 1000000000.0); + return set; } } |
