简体   繁体   English

如何从 perf4j 日志文件制作图形?

[英]How to make graph from perf4j log file?

I have used perf4j to calculate the performance of the process.我已经使用 perf4j 来计算进程的性能。 Now I want to make the graph for that file.现在我想为该文件制作图表。 Is it possible to make it without using Google API or any other method that can be used?是否可以不使用 Google API 或任何其他可以使用的方法来制作它?

You have a couple of options:你有几个选择:

  1. When you use the org.perf4j.LogParser to parse your log, you can use the "--format csv" option to generate CSV output, open this up in Excel, then create a graph in Excel.当您使用 org.perf4j.LogParser 解析您的日志时,您可以使用“--format csv”选项来生成 CSV 输出,在 Excel 中打开它,然后在 Excel 中创建一个图表。
  2. As the other poster said, I'm not sure why you're against using the Google Chart API, but if you are dead set against using it, note that the JFreeChart guys provide an implementation of the Google Chart APIs called Eastwood Charts: http://www.jfree.org/eastwood/ .正如另一张海报所说,我不确定您为什么反对使用 Google Chart API,但是如果您坚决反对使用它,请注意 JFreeChart 人员提供了一个名为 Eastwood Charts 的 Google Chart API 实现: http ://www.jfree.org/eastwood/ You could just set up an eastwood server and then proxy (or just set up in a hosts file) chart.apis.google .您可以设置一个 Eastwood 服务器,然后代理(或仅在主机文件中设置) chart.apis.google 。 com to your eastwood server. com 到您的伊斯特伍德服务器。 Alternatively, if you look at the org.perf4j.LogParser class, you can override the newMeanTimeChartGenerator and newTpsChartGenerator methods to call the GoogleChartGenerator constructor that takes the base URL.或者,如果您查看 org.perf4j.LogParser 类,您可以覆盖 newMeanTimeChartGenerator 和 newTpsChartGenerator 方法来调用采用基本 URL 的 GoogleChartGenerator 构造函数。
  3. You can always create another implementation of the StatisticsChartGenerator interface and use this instead.您始终可以创建 StatisticsChartGenerator 接口的另一个实现并改用它。 Obviously this is the most involved option.显然,这是最复杂的选择。

Can you explain a bit more as to why you want to avoid Google Charting APIs (I ask since I am intrigued as to why someone would not want to do something that is very simple, elegant and FREE)?您能否解释一下为什么要避免使用 Google Charting API(我之所以这么问,是因为我很好奇为什么有人不想做一些非常简单、优雅和免费的事情)?

Also there is a GraphingServlet section "Exposing Performance Graphs in a Web Application" which I think internally does the same thing.还有一个GraphingServlet部分“在 Web 应用程序中公开性能图”,我认为它在内部做了同样的事情。

If you still want you can take the graph data (in raw csv format) and write some helper classes to create charts using libraries like jfreechart (rich client)如果您仍然需要,您可以获取图形数据(以原始 csv 格式)并编写一些帮助类来使用 jfreechart(富客户端)等库创建图表

follow the following steps;请按照以下步骤操作;

  1. Go to the location where your perf4j log file exits and open command prompt there.转到 perf4j 日志文件所在的位置并在那里打开命令提示符。
  2. Hit the following command in cmd, make sure you have java(jdk) path set as environment variable and perf4j jar on this location:在 cmd 中输入以下命令,确保在此位置将 java(jdk) 路径设置为环境变量和 perf4j jar:

java -jar perf4j-0.9.16.jar --graph perfGraphs.html perfLogFile.log java -jar perf4j-0.9.16.jar --graph perfGraphs.html perfLogFile.log

this will generate perfGraphs.html file in this location, which consists of graphs.这将在此位置生成 perfGraphs.html 文件,该文件由图形组成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM