YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/util/stats/iostats_context_imp.cc
Line
Count
Source
1
// Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
2
// This source code is licensed under the BSD-style license found in the
3
// LICENSE file in the root directory of this source tree. An additional grant
4
// of patent rights can be found in the PATENTS file in the same directory.
5
//
6
// The following only applies to changes made to this file as part of YugaByte development.
7
//
8
// Portions Copyright (c) YugaByte, Inc.
9
//
10
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
11
// in compliance with the License.  You may obtain a copy of the License at
12
//
13
// http://www.apache.org/licenses/LICENSE-2.0
14
//
15
// Unless required by applicable law or agreed to in writing, software distributed under the License
16
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
17
// or implied.  See the License for the specific language governing permissions and limitations
18
// under the License.
19
//
20
21
#include "yb/util/stats/iostats_context_imp.h"
22
23
#include <sstream>
24
25
namespace yb {
26
27
#ifndef IOS_CROSS_COMPILE
28
# ifdef _WIN32
29
__declspec(thread) IOStatsContext iostats_context;
30
# else
31
__thread IOStatsContext iostats_context;
32
# endif
33
#endif  // IOS_CROSS_COMPILE
34
35
1
void IOStatsContext::Reset(uint64_t _thread_pool_id) {
36
1
  thread_pool_id = _thread_pool_id;
37
1
  bytes_read = 0;
38
1
  bytes_written = 0;
39
1
  open_nanos = 0;
40
1
  allocate_nanos = 0;
41
1
  write_nanos = 0;
42
1
  read_nanos = 0;
43
1
  range_sync_nanos = 0;
44
1
  prepare_write_nanos = 0;
45
1
  fsync_nanos = 0;
46
1
  logger_nanos = 0;
47
1
}
48
49
#define IOSTATS_CONTEXT_OUTPUT(counter)         \
50
22
  if (!exclude_zero_counters || 
counter > 011
) { \
51
12
    ss << #counter << " = " << counter << ", "; \
52
12
  }
53
54
2
std::string IOStatsContext::ToString(bool exclude_zero_counters) const {
55
2
  std::ostringstream ss;
56
2
  IOSTATS_CONTEXT_OUTPUT(thread_pool_id);
57
2
  IOSTATS_CONTEXT_OUTPUT(bytes_read);
58
2
  IOSTATS_CONTEXT_OUTPUT(bytes_written);
59
2
  IOSTATS_CONTEXT_OUTPUT(open_nanos);
60
2
  IOSTATS_CONTEXT_OUTPUT(allocate_nanos);
61
2
  IOSTATS_CONTEXT_OUTPUT(write_nanos);
62
2
  IOSTATS_CONTEXT_OUTPUT(read_nanos);
63
2
  IOSTATS_CONTEXT_OUTPUT(range_sync_nanos);
64
2
  IOSTATS_CONTEXT_OUTPUT(fsync_nanos);
65
2
  IOSTATS_CONTEXT_OUTPUT(prepare_write_nanos);
66
2
  IOSTATS_CONTEXT_OUTPUT(logger_nanos);
67
68
2
  return ss.str();
69
2
}
70
71
}  // namespace yb