Java性能计时库 [英] Java performance timing library

查看:151
本文介绍了Java性能计时库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我频繁地将代码包装在 System.nanoTime()对以对其进行计时。类似于:

I frequent wrap code in a System.nanoTime() pair in order to timing it. Something like:

long start = System.nanoTime();    
methodToBeTimed();
long elapsedTime = System.nanoTime() - start;

有什么好的计时库可以解决这个问题吗?也会接受自己开发的代码。

There is any good timing library that helps with this problem? Also homegrown code will be accepted.

NB

分析器不是解决方案,因为我想要在我的单元测试中强制执行一些时间限制,所以我想计划方法以编程方式

A profiler is not a solution here, since I want to enforce some time constraints in my unit tests, so I want to timing methods programmatically.

推荐答案

我我没有使用它,但我最近遇到了 perf4j

I haven't used it but I came across perf4j recently.

这篇关于Java性能计时库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆