Class HarTiming


  • public class HarTiming
    extends java.lang.Object
    This 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
      boolean equals​(java.lang.Object o)  
      int getBlocked()  
      long getBlocked​(java.util.concurrent.TimeUnit timeUnit)  
      java.lang.String getComment()  
      int getConnect()  
      long getConnect​(java.util.concurrent.TimeUnit timeUnit)  
      int getDns()  
      long getDns​(java.util.concurrent.TimeUnit timeUnit)  
      int getReceive()  
      long getReceive​(java.util.concurrent.TimeUnit timeUnit)  
      int getSend()  
      long getSend​(java.util.concurrent.TimeUnit timeUnit)  
      int getSsl()  
      long getSsl​(java.util.concurrent.TimeUnit timeUnit)  
      int getWait()  
      long getWait​(java.util.concurrent.TimeUnit timeUnit)  
      int hashCode()  
      void setBlocked​(long blocked, java.util.concurrent.TimeUnit timeUnit)  
      void setBlocked​(java.lang.Integer blocked)  
      void setComment​(java.lang.String comment)  
      void setConnect​(long connect, java.util.concurrent.TimeUnit timeUnit)  
      void setConnect​(java.lang.Integer connect)  
      void setDns​(long dns, java.util.concurrent.TimeUnit timeUnit)  
      void setDns​(java.lang.Integer dns)  
      void setReceive​(long receive, java.util.concurrent.TimeUnit timeUnit)  
      void setReceive​(java.lang.Integer receive)  
      void setSend​(long send, java.util.concurrent.TimeUnit timeUnit)  
      void setSend​(java.lang.Integer send)  
      void setSsl​(long ssl, java.util.concurrent.TimeUnit timeUnit)  
      void setSsl​(java.lang.Integer ssl)  
      void setWait​(long wait, java.util.concurrent.TimeUnit timeUnit)  
      void setWait​(java.lang.Integer wait)  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HarTiming

        public HarTiming()
    • 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:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object