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: 24 28 85.7 %
Date: 2020-09-03 22:13:26 Branches: 4 6 66.7 %

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
2
void Histogram::Reset() {
13
2
  hdr_reset(histogram_.get());
14
2
}
15
16
1837
bool Histogram::Record(int64_t value) {
17
1837
  return hdr_record_value(histogram_.get(), value);
18
}
19
20
2
int64_t Histogram::Min() {
21
2
  return hdr_min(histogram_.get());
22
}
23
24
2
int64_t Histogram::Max() {
25
2
  return hdr_max(histogram_.get());
26
}
27
28
2
double Histogram::Mean() {
29
2
  return hdr_mean(histogram_.get());
30
}
31
32
2
double Histogram::Stddev() {
33
2
  return hdr_stddev(histogram_.get());
34
}
35
36
991
double Histogram::Percentile(double percentile) {
37
991
  CHECK_GT(percentile, 0);
38
991
  CHECK_LE(percentile, 100);
39
  return static_cast<double>(
40
991
      hdr_value_at_percentile(histogram_.get(), percentile));
41
}
42
43
template <typename Iterator>
44
2
void Histogram::Percentiles(Iterator&& fn) {
45
  hdr_iter iter;
46
2
  hdr_iter_percentile_init(&iter, histogram_.get(), 1);
47
30
  while (hdr_iter_next(&iter)) {
48
14
    double key = iter.specifics.percentiles.percentile;
49
14
    double value = static_cast<double>(iter.value);
50
14
    fn(key, value);
51
  }
52
2
}
53
54
bool HistogramBase::RecordDelta() {
55
  uint64_t time = uv_hrtime();
56
  bool ret = true;
57
  if (prev_ > 0) {
58
    int64_t delta = time - prev_;
59
    if (delta > 0) {
60
      ret = Record(delta);
61
      TraceDelta(delta);
62
      if (!ret) {
63
        if (exceeds_ < 0xFFFFFFFF)
64
          exceeds_++;
65
        TraceExceeds(delta);
66
      }
67
    }
68
  }
69
  prev_ = time;
70
  return ret;
71
}
72
73
void HistogramBase::ResetState() {
74
  Reset();
75
  exceeds_ = 0;
76
  prev_ = 0;
77
}
78
79
}  // namespace node
80
81
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
82
83
#endif  // SRC_HISTOGRAM_INL_H_