GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/histogram-inl.h Lines: 0 46 0.0 %
Date: 2021-02-19 04:08:54 Branches: 0 18 0.0 %

Line Branch Exec Source
1
#ifndef SRC_HISTOGRAM_INL_H_
2
#define SRC_HISTOGRAM_INL_H_
3
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6
#include "histogram.h"
7
#include "base_object-inl.h"
8
#include "node_internals.h"
9
10
namespace node {
11
12
void Histogram::Reset() {
13
  Mutex::ScopedLock lock(mutex_);
14
  hdr_reset(histogram_.get());
15
  exceeds_ = 0;
16
  prev_ = 0;
17
}
18
19
int64_t Histogram::Min() {
20
  Mutex::ScopedLock lock(mutex_);
21
  return hdr_min(histogram_.get());
22
}
23
24
int64_t Histogram::Max() {
25
  Mutex::ScopedLock lock(mutex_);
26
  return hdr_max(histogram_.get());
27
}
28
29
double Histogram::Mean() {
30
  Mutex::ScopedLock lock(mutex_);
31
  return hdr_mean(histogram_.get());
32
}
33
34
double Histogram::Stddev() {
35
  Mutex::ScopedLock lock(mutex_);
36
  return hdr_stddev(histogram_.get());
37
}
38
39
double Histogram::Percentile(double percentile) {
40
  Mutex::ScopedLock lock(mutex_);
41
  CHECK_GT(percentile, 0);
42
  CHECK_LE(percentile, 100);
43
  return static_cast<double>(
44
      hdr_value_at_percentile(histogram_.get(), percentile));
45
}
46
47
template <typename Iterator>
48
void Histogram::Percentiles(Iterator&& fn) {
49
  Mutex::ScopedLock lock(mutex_);
50
  hdr_iter iter;
51
  hdr_iter_percentile_init(&iter, histogram_.get(), 1);
52
  while (hdr_iter_next(&iter)) {
53
    double key = iter.specifics.percentiles.percentile;
54
    double value = static_cast<double>(iter.value);
55
    fn(key, value);
56
  }
57
}
58
59
bool Histogram::Record(int64_t value) {
60
  Mutex::ScopedLock lock(mutex_);
61
  return hdr_record_value(histogram_.get(), value);
62
}
63
64
uint64_t Histogram::RecordDelta() {
65
  Mutex::ScopedLock lock(mutex_);
66
  uint64_t time = uv_hrtime();
67
  uint64_t delta = 0;
68
  if (prev_ > 0) {
69
    delta = time - prev_;
70
    if (delta > 0) {
71
      if (!hdr_record_value(histogram_.get(), delta) && exceeds_ < 0xFFFFFFFF)
72
        exceeds_++;
73
    }
74
  }
75
  prev_ = time;
76
  return delta;
77
}
78
79
size_t Histogram::GetMemorySize() const {
80
  Mutex::ScopedLock lock(mutex_);
81
  return hdr_get_memory_size(histogram_.get());
82
}
83
84
}  // namespace node
85
86
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
87
88
#endif  // SRC_HISTOGRAM_INL_H_