diff options
Diffstat (limited to 'examples/api/java/Statistics.java')
-rw-r--r-- | examples/api/java/Statistics.java | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/examples/api/java/Statistics.java b/examples/api/java/Statistics.java index e524eb3e3..751dda947 100644 --- a/examples/api/java/Statistics.java +++ b/examples/api/java/Statistics.java @@ -23,43 +23,45 @@ public class Statistics { public static void main(String[] args) { - Solver solver = getSolver(); - // Get the statistics from the `Solver` and iterate over them. The - // `Statistics` class implements the `Iterable<Pair<String, Stat>>` interface. - io.github.cvc5.api.Statistics stats = solver.getStatistics(); - // short version - System.out.println("Short version:"); - System.out.println(stats); + try (Solver solver = new Solver()) + { + // Get the statistics from the `Solver` and iterate over them. The + // `Statistics` class implements the `Iterable<Pair<String, Stat>>` interface. + io.github.cvc5.api.Statistics stats = solver.getStatistics(); + // short version + System.out.println("Short version:"); + System.out.println(stats); - System.out.println("-------------------------------------------------------"); + System.out.println("-------------------------------------------------------"); - System.out.println("Long version:"); + System.out.println("Long version:"); - // long version - for (Pair<String, Stat> pair : stats) - { - Stat stat = pair.second; - if (stat.isInt()) - { - System.out.println(pair.first + " = " + stat.getInt()); - } - else if (stat.isDouble()) - { - System.out.println(pair.first + " = " + stat.getDouble()); - } - else if (stat.isString()) - { - System.out.println(pair.first + " = " + stat.getString()); - } - else if (stat.isHistogram()) + // long version + for (Pair<String, Stat> pair : stats) { - System.out.println("-------------------------------------------------------"); - System.out.println(pair.first + " : Map"); - for (Map.Entry<String, Long> entry : stat.getHistogram().entrySet()) + Stat stat = pair.second; + if (stat.isInt()) + { + System.out.println(pair.first + " = " + stat.getInt()); + } + else if (stat.isDouble()) + { + System.out.println(pair.first + " = " + stat.getDouble()); + } + else if (stat.isString()) + { + System.out.println(pair.first + " = " + stat.getString()); + } + else if (stat.isHistogram()) { - System.out.println(entry.getKey() + " = " + entry.getValue()); + System.out.println("-------------------------------------------------------"); + System.out.println(pair.first + " : Map"); + for (Map.Entry<String, Long> entry : stat.getHistogram().entrySet()) + { + System.out.println(entry.getKey() + " = " + entry.getValue()); + } + System.out.println("-------------------------------------------------------"); } - System.out.println("-------------------------------------------------------"); } } } |