Package com.browserup.harreader.model
Class HarTiming
- java.lang.Object
-
- com.browserup.harreader.model.HarTiming
-
public class HarTiming extends java.lang.ObjectThis class is a merge of these 2 HarTiming implementations: * https://github.com/lightbody/browsermob-proxy/blob/master/browsermob-core/src/main/java/net/lightbody/bmp/core/har/HarTimings.java * https://github.com/sdstoehr/har-reader/blob/master/src/main/java/de/sstoehr/harreader/model/HarTiming.java It primarily differs from the de.sdstoehr implementation in that it internally stores metrics with nanosecond precision. In the JSON serialized form, the nanoseconds are converted to milliseconds, in accordance with the HAR spec. Some precision is lost in the TimeUnit conversion. Specifically, TimeUnit will truncate the Long nanosecond value to fit into an Integer, without rounding. For example, 999,999 ns == 0 ms, and 1,000,000 ns = 1 ms. Storing the times internally as nanoseconds makes it easier to write unit tests, such as when checking that fast-running operations took > 0ms to complete. The de.sdstoehr implementation differs from the lightbody implementation in that it serializes both ways, and is more up to date on the HAR specification, such as it supports additional fields added to metrics.
-
-
Constructor Summary
Constructors Constructor Description HarTiming()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)intgetBlocked()longgetBlocked(java.util.concurrent.TimeUnit timeUnit)java.lang.StringgetComment()intgetConnect()longgetConnect(java.util.concurrent.TimeUnit timeUnit)intgetDns()longgetDns(java.util.concurrent.TimeUnit timeUnit)intgetReceive()longgetReceive(java.util.concurrent.TimeUnit timeUnit)intgetSend()longgetSend(java.util.concurrent.TimeUnit timeUnit)intgetSsl()longgetSsl(java.util.concurrent.TimeUnit timeUnit)intgetWait()longgetWait(java.util.concurrent.TimeUnit timeUnit)inthashCode()voidsetBlocked(long blocked, java.util.concurrent.TimeUnit timeUnit)voidsetBlocked(java.lang.Integer blocked)voidsetComment(java.lang.String comment)voidsetConnect(long connect, java.util.concurrent.TimeUnit timeUnit)voidsetConnect(java.lang.Integer connect)voidsetDns(long dns, java.util.concurrent.TimeUnit timeUnit)voidsetDns(java.lang.Integer dns)voidsetReceive(long receive, java.util.concurrent.TimeUnit timeUnit)voidsetReceive(java.lang.Integer receive)voidsetSend(long send, java.util.concurrent.TimeUnit timeUnit)voidsetSend(java.lang.Integer send)voidsetSsl(long ssl, java.util.concurrent.TimeUnit timeUnit)voidsetSsl(java.lang.Integer ssl)voidsetWait(long wait, java.util.concurrent.TimeUnit timeUnit)voidsetWait(java.lang.Integer wait)
-
-
-
Method Detail
-
getBlocked
public long getBlocked(java.util.concurrent.TimeUnit timeUnit)
- Parameters:
timeUnit- param- Returns:
- Time spent in a queue waiting for a network connection. -1 if the timing does not apply to the current request.
-
setBlocked
public void setBlocked(long blocked, java.util.concurrent.TimeUnit timeUnit)
-
getDns
public long getDns(java.util.concurrent.TimeUnit timeUnit)
- Parameters:
timeUnit- param- Returns:
- DNS resolution time. The time required to resolve a host name. -1 if the timing does not apply to the current request.
-
setDns
public void setDns(long dns, java.util.concurrent.TimeUnit timeUnit)
-
getConnect
public long getConnect(java.util.concurrent.TimeUnit timeUnit)
- Parameters:
timeUnit- param- Returns:
- Time required to create TCP connection. -1 if the timing does not apply to the current request.
-
setConnect
public void setConnect(long connect, java.util.concurrent.TimeUnit timeUnit)
-
getSend
public long getSend(java.util.concurrent.TimeUnit timeUnit)
- Parameters:
timeUnit- param- Returns:
- Time required to send HTTP request to the server, 0 if not present. According to the HAR spec, the send, wait and receive timings are not optional and must have non-negative values.
-
setSend
public void setSend(long send, java.util.concurrent.TimeUnit timeUnit)
-
getWait
public long getWait(java.util.concurrent.TimeUnit timeUnit)
- Parameters:
timeUnit- param- Returns:
- Time spent waiting for a response from the server, 0 if not present. According to the HAR spec, the send, wait and receive timings are not optional and must have non-negative values.
-
setWait
public void setWait(long wait, java.util.concurrent.TimeUnit timeUnit)
-
getReceive
public long getReceive(java.util.concurrent.TimeUnit timeUnit)
- Parameters:
timeUnit- param- Returns:
- Time spent reading the entire response from the server, 0 if not present. According to the HAR spec, the send, wait and receive timings are not optional and must have non-negative values.
-
setReceive
public void setReceive(long receive, java.util.concurrent.TimeUnit timeUnit)
-
getSsl
public long getSsl(java.util.concurrent.TimeUnit timeUnit)
- Parameters:
timeUnit- param- Returns:
- Time required for SSL/TLS negotiation. If this field is defined then the time is also included in the connect field (to ensure backward compatibility with HAR 1.1). -1 if the timing does not apply to the current request.
-
setSsl
public void setSsl(long ssl, java.util.concurrent.TimeUnit timeUnit)
-
getBlocked
public int getBlocked()
- Returns:
- Time spent in a queue waiting for a network connection, in milliseconds. -1 if the timing does not apply to the current request.
-
setBlocked
public void setBlocked(java.lang.Integer blocked)
-
getDns
public int getDns()
- Returns:
- DNS resolution time. The time required to resolve a host name. -1 if the timing does not apply to the current request.
-
setDns
public void setDns(java.lang.Integer dns)
-
getConnect
public int getConnect()
- Returns:
- Time required to create TCP connection. -1 if the timing does not apply to the current request.
-
setConnect
public void setConnect(java.lang.Integer connect)
-
getSend
public int getSend()
- Returns:
- Time required to send HTTP request to the server, in milliseconds. Returns 0 if not present. According to the HAR spec, the send, wait and receive timings are not optional and must have non-negative values.
-
setSend
public void setSend(java.lang.Integer send)
-
getWait
public int getWait()
- Returns:
- Time spent waiting for a response from the server, in milliseconds. Returns 0 if not present. According to the HAR spec, the send, wait and receive timings are not optional and must have non-negative values.
-
setWait
public void setWait(java.lang.Integer wait)
-
getReceive
public int getReceive()
- Returns:
- Time spent reading the entire response from the server, in milliseconds. Returns 0 if not present. According to the HAR spec, the send, wait and receive timings are not optional and must have non-negative values.
-
setReceive
public void setReceive(java.lang.Integer receive)
-
getSsl
public int getSsl()
- Returns:
- Time required for SSL/TLS negotiation. If this field is defined then the time is also included in the connect field (to ensure backward compatibility with HAR 1.1). -1 if the timing does not apply to the current request.
-
setSsl
public void setSsl(java.lang.Integer ssl)
-
getComment
public java.lang.String getComment()
- Returns:
- Comment provided by the user or application, null if not present.
-
setComment
public void setComment(java.lang.String comment)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-