< prev index next >

src/hotspot/share/runtime/timer.hpp

Print this page
*** 27,30 ***
  
  #include "utilities/globalDefinitions.hpp"
  
  // Timers for simple measurement.
  
! class elapsedTimer {
    friend class VMStructs;
!  private:
    jlong _counter;
    jlong _start_counter;
    bool  _active;
   public:
!   elapsedTimer()             { _active = false; reset(); }
!   void add(elapsedTimer t);
    void add_nanoseconds(jlong ns);
!   void start();
!   void stop();
    void reset()               { _counter = 0; }
    double seconds() const;
    jlong milliseconds() const;
    jlong ticks() const        { return _counter; }
    jlong active_ticks() const;
    bool  is_active() const { return _active; }
  };
  
  // TimeStamp is used for recording when an event took place.
  class TimeStamp {
   private:
    jlong _counter;
   public:
--- 27,53 ---
  
  #include "utilities/globalDefinitions.hpp"
  
  // Timers for simple measurement.
  
! class BaseTimer {
    friend class VMStructs;
!  protected:
    jlong _counter;
    jlong _start_counter;
    bool  _active;
+ 
+   virtual jlong read_counter() const = 0;
+ 
   public:
!   BaseTimer() {
!     _active = false;
+     reset();
+   }
+   void add(BaseTimer* t);
    void add_nanoseconds(jlong ns);
!   virtual void start();
!   virtual void stop();
    void reset()               { _counter = 0; }
    double seconds() const;
    jlong milliseconds() const;
    jlong ticks() const        { return _counter; }
    jlong active_ticks() const;
    bool  is_active() const { return _active; }
  };
  
+ class elapsedTimer: public BaseTimer {
+   friend class VMStructs;
+  public:
+   jlong read_counter() const override;
+ };
+ 
+ class ThreadTimer: public BaseTimer {
+  private:
+   Thread* _owner;
+  public:
+   ThreadTimer();
+   ThreadTimer(Thread* thread) : _owner(thread) {}
+   void start() override;
+   void stop() override;
+   jlong read_counter() const override;
+ };
+ 
  // TimeStamp is used for recording when an event took place.
  class TimeStamp {
   private:
    jlong _counter;
   public:
< prev index next >