252 253 virtual void register_start(const Ticks& start) const; 254 virtual void register_end(const Ticks& start, const Ticks& end) const; 255 }; 256 257 class ZStatCriticalPhase : public ZStatPhase { 258 private: 259 const ZStatCounter _counter; 260 const bool _verbose; 261 262 public: 263 ZStatCriticalPhase(const char* name, bool verbose = true); 264 265 virtual void register_start(const Ticks& start) const; 266 virtual void register_end(const Ticks& start, const Ticks& end) const; 267 }; 268 269 // 270 // Stat timer 271 // 272 class ZStatTimer : public StackObj { 273 private: 274 const ZStatPhase& _phase; 275 const Ticks _start; 276 277 public: 278 ZStatTimer(const ZStatPhase& phase) : 279 _phase(phase), 280 _start(Ticks::now()) { 281 _phase.register_start(_start); 282 } 283 284 ~ZStatTimer() { 285 const Ticks end = Ticks::now(); 286 _phase.register_end(_start, end); 287 } 288 }; 289 290 // 291 // Stat sample/increment 292 // 293 void ZStatSample(const ZStatSampler& sampler, uint64_t value, bool trace = ZStatisticsForceTrace); 294 void ZStatInc(const ZStatCounter& counter, uint64_t increment = 1, bool trace = ZStatisticsForceTrace); 295 void ZStatInc(const ZStatUnsampledCounter& counter, uint64_t increment = 1); 296 297 // 298 // Stat allocation rate 299 // 300 class ZStatAllocRate : public AllStatic { 301 private: 302 static const ZStatUnsampledCounter _counter; 303 static TruncatedSeq _rate; // B/s 304 static TruncatedSeq _rate_avg; // B/s 305 306 public: | 252 253 virtual void register_start(const Ticks& start) const; 254 virtual void register_end(const Ticks& start, const Ticks& end) const; 255 }; 256 257 class ZStatCriticalPhase : public ZStatPhase { 258 private: 259 const ZStatCounter _counter; 260 const bool _verbose; 261 262 public: 263 ZStatCriticalPhase(const char* name, bool verbose = true); 264 265 virtual void register_start(const Ticks& start) const; 266 virtual void register_end(const Ticks& start, const Ticks& end) const; 267 }; 268 269 // 270 // Stat timer 271 // 272 class ZStatTimerDisable : public StackObj { 273 private: 274 static __thread uint32_t _active; 275 276 public: 277 ZStatTimerDisable() { 278 _active++; 279 } 280 281 ~ZStatTimerDisable() { 282 _active--; 283 } 284 285 static bool is_active() { 286 return _active > 0; 287 } 288 }; 289 290 class ZStatTimer : public StackObj { 291 private: 292 const bool _enabled; 293 const ZStatPhase& _phase; 294 const Ticks _start; 295 296 public: 297 ZStatTimer(const ZStatPhase& phase) : 298 _enabled(!ZStatTimerDisable::is_active()), 299 _phase(phase), 300 _start(Ticks::now()) { 301 if (_enabled) { 302 _phase.register_start(_start); 303 } 304 } 305 306 ~ZStatTimer() { 307 if (_enabled) { 308 const Ticks end = Ticks::now(); 309 _phase.register_end(_start, end); 310 } 311 } 312 }; 313 314 // 315 // Stat sample/increment 316 // 317 void ZStatSample(const ZStatSampler& sampler, uint64_t value, bool trace = ZStatisticsForceTrace); 318 void ZStatInc(const ZStatCounter& counter, uint64_t increment = 1, bool trace = ZStatisticsForceTrace); 319 void ZStatInc(const ZStatUnsampledCounter& counter, uint64_t increment = 1); 320 321 // 322 // Stat allocation rate 323 // 324 class ZStatAllocRate : public AllStatic { 325 private: 326 static const ZStatUnsampledCounter _counter; 327 static TruncatedSeq _rate; // B/s 328 static TruncatedSeq _rate_avg; // B/s 329 330 public: |