1 /*
2 * Copyright (C) 2017, Google Inc.
3 * and other copyright owners as documented in the project's IP log.
4 *
5 * This program and the accompanying materials are made available
6 * under the terms of the Eclipse Distribution License v1.0 which
7 * accompanies this distribution, is reproduced below, and is
8 * available at http://www.eclipse.org/org/documents/edl-v10.php
9 *
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
14 * conditions are met:
15 *
16 * - Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 *
19 * - Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials provided
22 * with the distribution.
23 *
24 * - Neither the name of the Eclipse Foundation, Inc. nor the
25 * names of its contributors may be used to endorse or promote
26 * products derived from this software without specific prior
27 * written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
30 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
31 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
32 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
34 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
36 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
37 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
38 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
41 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 */
43
44 package org.eclipse.jgit.internal.storage.dfs;
45
46 /** IO statistics for a {@link DfsReader}. */
47 public class DfsReaderIoStats {
48 /** POJO to accumulate IO statistics. */
49 public static class Accumulator {
50 /** Number of times the reader explicitly called scanPacks. */
51 long scanPacks;
52
53 /** Total number of complete pack indexes read into memory. */
54 long readIdx;
55
56 /** Total number of complete bitmap indexes read into memory. */
57 long readBitmap;
58
59 /** Total number of bytes read from indexes. */
60 long readIdxBytes;
61
62 /** Total microseconds spent reading pack or bitmap indexes. */
63 long readIdxMicros;
64
65 /** Total number of block cache hits. */
66 long blockCacheHit;
67
68 /** Total number of discrete blocks read from pack file(s). */
69 long readBlock;
70
71 /** Total number of compressed bytes read as block sized units. */
72 long readBlockBytes;
73
74 /** Total microseconds spent reading {@link #readBlock} blocks. */
75 long readBlockMicros;
76
77 /** Total number of bytes decompressed. */
78 long inflatedBytes;
79
80 Accumulator() {
81 }
82 }
83
84 private final Accumulator stats;
85
86 DfsReaderIoStats(Accumulator stats) {
87 this.stats = stats;
88 }
89
90 /** @return number of times the reader explicitly called scanPacks. */
91 public long getScanPacks() {
92 return stats.scanPacks;
93 }
94
95 /** @return total number of complete pack indexes read into memory. */
96 public long getReadPackIndexCount() {
97 return stats.readIdx;
98 }
99
100 /** @return total number of complete bitmap indexes read into memory. */
101 public long getReadBitmapIndexCount() {
102 return stats.readBitmap;
103 }
104
105 /** @return total number of bytes read from indexes. */
106 public long getReadIndexBytes() {
107 return stats.readIdxBytes;
108 }
109
110 /** @return total microseconds spent reading pack or bitmap indexes. */
111 public long getReadIndexMicros() {
112 return stats.readIdxMicros;
113 }
114
115 /** @return total number of block cache hits. */
116 public long getBlockCacheHits() {
117 return stats.blockCacheHit;
118 }
119
120 /** @return total number of discrete blocks read from pack file(s). */
121 public long getReadBlocksCount() {
122 return stats.readBlock;
123 }
124
125 /** @return total number of compressed bytes read as block sized units. */
126 public long getReadBlocksBytes() {
127 return stats.readBlockBytes;
128 }
129
130 /** @return total microseconds spent reading blocks. */
131 public long getReadBlocksMicros() {
132 return stats.readBlockMicros;
133 }
134
135 /** @return total number of bytes decompressed. */
136 public long getInflatedBytes() {
137 return stats.inflatedBytes;
138 }
139 }