美文网首页我爱编程
在spring中使用StopWatch

在spring中使用StopWatch

作者: 仙境999 | 来源:发表于2018-04-16 15:26 被阅读0次
        @Test
        public void stopWatch(){
            StopWatch stopWatch = new StopWatch();
            stopWatch.start("selectAll");
    
            List<User> list = userMapper.selectAll();
    
            stopWatch.stop();
    
            stopWatch.start("findByName");
            List<User> byNameList = userMapper.findByName("b7");
    
            stopWatch.stop();
            System.out.println(stopWatch.prettyPrint());
        }
    

    展示为:

    StopWatch '': running time (millis) = 107
    -----------------------------------------
    ms     %     Task name
    -----------------------------------------
    00100  093%  selectAll
    00007  007%  findByName
    

    一个StopWatch可以start多个task, 但是同一时间只能运行一个task, (所以stopWatch.stop()的时候不需要指定名称)

    相关文章

      网友评论

        本文标题:在spring中使用StopWatch

        本文链接:https://www.haomeiwen.com/subject/ybrekftx.html