commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ottobackwards <>
Subject [GitHub] commons-lang issue #311: LANG-1373 Stopwatch based capability for nested, na...
Date Tue, 27 Feb 2018 14:08:25 GMT
Github user ottobackwards commented on the issue:
    the static factory, is pretty straight forward.
    The try with resources, less so.  What ends up happening is you cannot stop the watch
before visiting the nodes.
    For example, this is what you want to do if you are going to time, but visit later:
        public void testTryWithResources() {
            final StopWatch stopWatch = new StopWatch();
            try(StackWatch<String,String> watch = new StackWatch<>("testStackWatch"))
            watch.visit(new StackWatch.TimingVisitor<String,String>() {
                public void visitTiming(int level, List<String> path, StackWatch.Timing<String,String>
node) {
                    assertTrue(node.getStopWatch().getNanoTime() > stopWatch.getNanoTime());
    but it won't work/compile with try with resources


View raw message