简体   繁体   English

如何在Web应用程序中查找加载页面的cpu,io,内存利用率

[英]How to find cpu,io,memory utilization of a loading page in web application

I've written a Java file, using Jsp,servlets, that I would like to perform run-time tests on. 我编写了一个Java文件,使用Jsp,servlets,我想对它进行运行时测试。 I've never done this before and was just curious on how to go about it. 我以前从未这样做过,只是对如何去做而感到好奇。

What I'm interested in knowing, besides the actual timings, is how to find cpu,memory and io utilization when running the application.Your thoughts are appreciated. 除了实际的时间之外,我还想知道如何在运行应用程序时找到cpu,内存和io利用率。我们的想法很受欢迎。

Typically you wouldn't measure these from within the application, but by running another tool on the same host. 通常,您不会在应用程序中测量这些,而是​​在同一主机上运行另一个工具。

If you just want to see the impact on the host operating system, you can use a program like top (on *nix boxes), or good old Task Manager on Windows, to see the CPU/memory/IO utilisation of your Java process (typically the servlet container such as Tomcat). 如果您只想查看对主机操作系统的影响,可以使用top (在* nix框上)或Windows上的旧任务管理器等程序来查看Java进程的CPU /内存/ IO利用率(通常是servlet容器,如Tomcat)。

If you want more detailed information on the actual Java process itself, you can connect JConsole or jvisualvm to get VM information (including memory and CPU) for the process itself. 如果您想了解有关实际Java进程本身的更多详细信息,可以连接JConsolejvisualvm以获取进程本身的VM信息(包括内存和CPU)。 (With Java 6 you should be able to do this from the local machine without passing any parameters to the Java process at startup; for Java 5, or remote connections, you'll need to pass command-line arguments to the Java process to allow (remote) JMX connections.) (使用Java 6,您应该能够从本地计算机执行此操作,而无需在启动时将任何参数传递给Java进程;对于Java 5或远程连接,您需要将命令行参数传递给Java进程以允许(远程)JMX连接。)

Finally, if you want really in-depth details of the resource usage, down to the performance of various methods (which it sounds like you're after), you'll need to use a profiler. 最后,如果你想真正深入的资源使用情况的详细信息,下至各种方法的性能(这听起来像你后),你需要使用一个分析器。 There are several of these for Java - with YourKit and JProfiler being the biggest commercial ones (in my unqualified opinion). Java中有以下几种 - 其中YourKit和JProfiler是最大的商业用户(根据我的无保留意见)。 I believe that the NetBeans IDE also has a decent profiler built-in. 我相信NetBeans IDE内置了一个不错的分析器。 The process for connecting these to your application would vary depending on the app itself, but these will all typically allow you to "drill down" into the CPU time to see which classes/methods took the most cycles to execute, and likewise to drill down into memory use to see which classes are taking up the most memory. 将这些连接到您的应用程序的过程将根据应用程序本身的不同而不同,但这些通常都允许您“深入”查看CPU时间,以查看哪些类/方法执行的周期最多,同样向下钻取进入内存使用以查看哪些类占用的内存最多。

The standard way to monitor running Java applications these days is sing JMX through the JConcole 现在监视运行Java应用程序的标准方法是通过JConcoleJMX

If your a using a commercial application server like Weblogic or WebSphere these have custom and powerful management consoles that provide the monitoring information you are looking for. 如果您使用商业应用程序服务器(如Weblogic或WebSphere),那么它们具有自定义且功能强大的管理控制台,可提供您正在寻找的监视信息。 The technology at the heart of these consoles is still JMX so these can also be monitored and managed using the standard JConsole. 这些控制台核心的技术仍然是JMX,因此也可以使用标准JConsole监控和管理这些技术。 This article shows how to do this for Weblogic . 本文介绍如何为Weblogic执行此操作

I guess you need this info in the client side (browser). 我猜你在客户端(浏览器)需要这个信息。 So it's not Java based question. 所以这不是基于Java的问题。

If so, here is my answer: I prefer using FireBug and ySlow extensions. 如果是这样,这是我的答案:我更喜欢使用FireBug和ySlow扩展。 They give performance information, memory information and much more. 它们提供性能信息,内存信息等等。

I combine it with using regular task-manager to view more information about the browser. 我将它与使用常规任务管理器相结合,以查看有关浏览器的更多信息。

BR BR

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

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