Performance Meters"

From Documentation
(Created page with '{{ZKDevelopersReferencePageHeader}} <javadoc type="interface">org.zkoss.zk.ui.util.PerformanceMeter</javadoc> is a collection of callbacks that the implementation could know whe…')
 
m
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{ZKDevelopersReferencePageHeader}}
 
{{ZKDevelopersReferencePageHeader}}
  
<javadoc type="interface">org.zkoss.zk.ui.util.PerformanceMeter</javadoc> is a collection of callbacks that the implementation could know when a request is sent, arrives and is processed.
+
__TOC__
 +
 
 +
<javadoc type="interface">org.zkoss.zk.ui.util.PerformanceMeter</javadoc> is a collection of callbacks that the implementation could know when a request is sent, arrives or is processed.
  
 
[[Image:performancemeter.png]]
 
[[Image:performancemeter.png]]
  
As show above, T1-T5 identifies the following callbacks.
+
As shown above, T1-T5 identifies the following callbacks.
 
* T1: <javadoc type="interface" method="requestStartAtClient (java.lang.String, org.zkoss.zk.ui.Execution, long)">org.zkoss.zk.ui.util.PerformanceMeter</javadoc>
 
* T1: <javadoc type="interface" method="requestStartAtClient (java.lang.String, org.zkoss.zk.ui.Execution, long)">org.zkoss.zk.ui.util.PerformanceMeter</javadoc>
 
* T2: <javadoc type="interface" method="requestStartAtServer(java.lang.String, org.zkoss.zk.ui.Execution, long)">org.zkoss.zk.ui.util.PerformanceMeter</javadoc>
 
* T2: <javadoc type="interface" method="requestStartAtServer(java.lang.String, org.zkoss.zk.ui.Execution, long)">org.zkoss.zk.ui.util.PerformanceMeter</javadoc>
Line 18: Line 20:
 
* Network Latency Time: (T4 - T3) + (T2 - T1)
 
* Network Latency Time: (T4 - T3) + (T2 - T1)
  
Notice that, when we make a connection to load a page for the first time, only Server Execution Time is available. T4 and T5 will be saved on the client side, and sent back along with the next request.
+
= How it works =
 +
Notice that, when we make a connection to load a page for the first time, only Server Execution Time is available. T4 and T5 will be saved on the client-side and sent back along with the next request.
 +
 
 +
If you print the request ID and the method name, when zk calls a performance monitor. You will see a different log between loading a zul and sending an AU request.
 +
 
 +
== Request a ZUL ==
 +
If load a zul 3 times:
 +
<syntaxhighlight lang='properties'>
 +
# first load zul
 +
requestId1st - requestStartAtServer
 +
requestId1st - requestCompleteAtServer
 +
 
 +
# 2nd load zul
 +
requestId1st - requestReceiveAtClient
 +
requestId1st - requestCompleteAtClient
 +
requestId2nd - requestStartAtServer
 +
requestId2nd - requestCompleteAtServer
 +
 
 +
# 3rd load zul
 +
requestId2nd - requestReceiveAtClient
 +
requestId2nd - requestCompleteAtClient
 +
requestId3rd - requestStartAtServer
 +
requestId3rd - requestCompleteAtServer
 +
</syntaxhighlight>
 +
 
 +
== Send AU Requests==
 +
If you send 2 AU requests, you will see a log like:
 +
<syntaxhighlight lang='properties' highlight='4'>
 +
# 1st au
 +
requestId - requestReceiveAtClient
 +
requestId - requestCompleteAtClient
 +
requestId-0 - requestStartAtClient
 +
requestId-0 - requestStartAtServer
 +
requestId-0 - requestCompleteAtServer
 +
 
 +
# 2nd au
 +
requestId-0 - requestReceiveAtClient
 +
requestId-0 - requestCompleteAtClient
 +
requestId-1 - requestStartAtClient
 +
requestId-1 - requestStartAtServer
 +
requestId-1 - requestCompleteAtServer
 +
</syntaxhighlight>
 +
* only when sending au request, zk calls <code>requestStartAtClient()</code>
  
Once implemented, you could register it by specifying the following in <tt>WEB-INF/zk.xml</tt> (assume the class is called foo.MyMeter):
+
= Register as a Listener =
 +
Once implemented, you need to register it as a [[ZK_Configuration_Reference/zk.xml/The_listener_Element| listener]] in <code>WEB-INF/zk.xml</code> to make it work: (assume the class is called foo.MyMeter):
  
 
<source lang="xml">
 
<source lang="xml">
<zk>
 
 
     <listener>
 
     <listener>
 
         <listener-class>foo.MyMeter</listener-class>
 
         <listener-class>foo.MyMeter</listener-class>
 
     </listener>
 
     </listener>
</zk>
 
 
</source>
 
</source>
  
=Version History=
+
 
{{LastUpdated}}
 
{| border='1px' | width="100%"
 
! Version !! Date !! Content
 
|-
 
| &nbsp;
 
| &nbsp;
 
| &nbsp;
 
|}
 
  
 
{{ZKDevelopersReferencePageFooter}}
 
{{ZKDevelopersReferencePageFooter}}

Latest revision as of 04:46, 2 February 2024

PerformanceMeter is a collection of callbacks that the implementation could know when a request is sent, arrives or is processed.

Performancemeter.png

As shown above, T1-T5 identifies the following callbacks.

Thus,

  • Server Execution Time: T3 - T2
  • Client Execution Time: T5 - T4
  • Network Latency Time: (T4 - T3) + (T2 - T1)

How it works

Notice that, when we make a connection to load a page for the first time, only Server Execution Time is available. T4 and T5 will be saved on the client-side and sent back along with the next request.

If you print the request ID and the method name, when zk calls a performance monitor. You will see a different log between loading a zul and sending an AU request.

Request a ZUL

If load a zul 3 times:

# first load zul
requestId1st - requestStartAtServer
requestId1st - requestCompleteAtServer

# 2nd load zul
requestId1st - requestReceiveAtClient
requestId1st - requestCompleteAtClient
requestId2nd - requestStartAtServer
requestId2nd - requestCompleteAtServer

# 3rd load zul
requestId2nd - requestReceiveAtClient
requestId2nd - requestCompleteAtClient
requestId3rd - requestStartAtServer
requestId3rd - requestCompleteAtServer

Send AU Requests

If you send 2 AU requests, you will see a log like:

# 1st au
requestId - requestReceiveAtClient
requestId - requestCompleteAtClient
requestId-0 - requestStartAtClient
requestId-0 - requestStartAtServer
requestId-0 - requestCompleteAtServer

# 2nd au
requestId-0 - requestReceiveAtClient
requestId-0 - requestCompleteAtClient
requestId-1 - requestStartAtClient
requestId-1 - requestStartAtServer
requestId-1 - requestCompleteAtServer
  • only when sending au request, zk calls requestStartAtClient()

Register as a Listener

Once implemented, you need to register it as a listener in WEB-INF/zk.xml to make it work: (assume the class is called foo.MyMeter):

    <listener>
        <listener-class>foo.MyMeter</listener-class>
    </listener>




Last Update : 2024/02/02

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.