Java 应用程序的性能分析器
我需要优化 Java 应用程序。它会拨打一些第 3 方电话。我需要一些好的工具来准确测量各个 API 调用所花费的时间。 给出复杂性的概念 - 该应用程序获取包含 100 万行的数据源文件,大约需要一小时才能完成处理。作为处理的一部分,它会进行一些第 3 方调用(包括一些网络调用)。我需要确定哪些调用比其他调用花费更多时间,并在此基础上找出优化应用程序的方法。
任何建议将不胜感激。
I need to optimise a Java application. It makes some 3rd party calls. I need some good tool to accurately measure the time taken by individual API calls.
To give an idea of complexity-
the application takes a data source file containing 1 million rows, and it takes around one hour to complete the processing. As a part of processing , it makes some 3rd party calls (including some network calls). I need to identify which calls are taking more time then others, and based on that, find out a way to optimise the application.
Any suggestions would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
在我们的办公室,我们每天都使用 YourKit 分析器。它的重量确实很轻,可以满足我们所拥有的大多数与性能相关的用例。
但我也用过Visual VM。它免费且快速。在使用 YourKit 之前,您可能首先想尝试一下 Visual VM(YourKit 不是免费软件)。
In our office we use YourKit profiler on a day to day basis. It's really light weight and serves most of the performance related use cases we have had.
But I have also used Visual VM. It's free and fast. You may first want to give Visual VM a try before going towards YourKit (YourKit is not freeware).
VisualVM(SDK 的一部分)和 Java 7 可以生成详细的分析。
visualvm (part of the SDK) and Java 7 can produce detailed profiling.
我在 NetBeans 中使用分析器(它非常出色并且已经内置,无需安装插件)或 JVisualVM(不使用 NetBeans 时)。
I use profiler in NetBeans (it is really brilliant and already built in, no need to install plugin) or JVisualVM when not using NetBeans.
在这种情况下,听起来普通的探查器可能不是正确的工具,因为它们的目的是测量被探查的程序所花费的 CPU 时间,而不是它调用的外部 API,并且它们往往会产生很高的开销。拥有并收集大量数据,如果长时间运行,这些数据可能会让您的系统不堪重负。
如果你确实需要收集这么长时间的性能数据,并且主要用于外部调用,那么 Perf4J 是可能是一个更好的工具。
It sounds like a normal profiler might not be the right tool in this case, since they're geared towards measuring the CPU time taken by the program being profiled rather than external APIs that it calls, and they tend to incur a high overhead of their own and collect a large amount of data that would probably overwhelm your system if left running for a long time.
If you really need to collect performance data over such a long time, and mainly for external calls, then Perf4J is probably a better tool.
我可以推荐 JVisualVM。它是一个很棒的监控/分析工具,与 Oracle/Sun JDK 捆绑在一起。只需启动它,连接到您的应用程序并开始 CPU 分析。您应该获得有关时间花费情况的出色直方图。
VisualVM 入门 有一个很棒的屏幕截图,向您展示如何使用它。
屏幕截图:
另一个更基本的替代方案是使用
-Xprof
命令行选项:I can recommend JVisualVM. It's a great monitoring / profiling tool that is bundled with the Oracle/Sun JDK. Just fire it up, connect to your application and start the CPU-profiling. You should get great histograms over where the time is spent.
Getting Started with VisualVM has a great screen-cast showing you how to work with it.
Screen shot:
Another more rudimentary alternative is to go with the
-Xprof
command line option:我已经使用 YourKit 几次了,并且非常满意。然而,我从未分析过长期运行的操作。
每行的处理是否相同?在这种情况下,输入文件的大小并不重要。您可以分析一个子集以找出哪些调用成本较高。
I've been using YourKit a few times and what quite happy with it. I've however never profiled a long-running operation.
Is the processing the same for each row? In which case the size of the input file doesn't really matter. You could profile a subset to figure out which calls are expensive.
只是想提一下spectIT 工具。它最近变得完全开源(https://github.com/inspectIT/inspectIT)。它提供了完整而详细的调用图以及上下文信息,有许多开箱即用的传感器用于数据库调用、http 监控、异常等。Seams
非常适合您的用例。
Just wanted to mention the inspectIT tool. It recently became completely open source (https://github.com/inspectIT/inspectIT). It provides complete and detailed call graph with contextual information, there are many out-of the box sensor for database calls, http monitoring, exceptions, etc.
Seams perfect for your use-case..
试用 OPNET 的 Panorama 软件产品
Try OPNET's Panorama software product