Slow problems using the Btrace positioning system

Source: Internet
Author: User

How can we locate these page requests when the system execution is inefficient when accessing page requests?

Java has a very effective dynamic tracking tool-btrace URL: https://kenai.com/projects/btrace/downloads

For example, you want to locate our controller code which methods are slow:

1. We can write the following classes:

Package demo;

Import Com.sun.btrace.annotations.BTrace;
Import Com.sun.btrace.annotations.Kind;
Import com.sun.btrace.annotations.Location;
Import Com.sun.btrace.annotations.OnMethod;
Import Com.sun.btrace.annotations.TLS;
Import static com.sun.btrace.btraceutils.*;


@BTrace
public class Btracetest {

@TLS
private static long starttime;


@OnMethod (clazz= "/com\\.hotent\\. *\\.. *\\.controller\\. */", method="/.+/", [email protected] (kind.entry))
public static void Startexecute () {
Starttime=timemillis ();
}

@OnMethod (clazz= "/com\\.hotent\\. *\\.. *\\.controller\\. */", method="/.+/", [email protected] (Kind.return))
public static void EndExecute () {
Long Timecost=timemillis ()-starttime;

Print (strcat (strcat (Name (Probeclass ()), "."), Probemethod ());

Print (Strcat (", Time Taken:", str (timecost)));

println ("]");
}
}

2. Use JPS to view the application server process.


8512 of them are our Tomcat process.

3. Copy the code you just made to the Btrace download directory.

4. Execute the command as follows

BTRACE.BAT-CP bulid 8512 Demo/btracetest.java

5. The results of the implementation are as follows :

The access page console will print the execution time for each controller method.

Use Btrace to locate slow problems in the system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.