View Javadoc
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  /**
47   * IO statistics for a {@link org.eclipse.jgit.internal.storage.dfs.DfsReader}.
48   */
49  public class DfsReaderIoStats {
50  	/** POJO to accumulate IO statistics. */
51  	public static class Accumulator {
52  		/** Number of times the reader explicitly called scanPacks. */
53  		long scanPacks;
54  
55  		/** Total number of complete pack indexes read into memory. */
56  		long readIdx;
57  
58  		/** Total number of complete bitmap indexes read into memory. */
59  		long readBitmap;
60  
61  		/** Total number of bytes read from indexes. */
62  		long readIdxBytes;
63  
64  		/** Total microseconds spent reading pack or bitmap indexes. */
65  		long readIdxMicros;
66  
67  		/** Total number of block cache hits. */
68  		long blockCacheHit;
69  
70  		/**
71  		 * Total number of discrete blocks actually read from pack file(s), that is,
72  		 * block cache misses.
73  		 */
74  		long readBlock;
75  
76  		/**
77  		 * Total number of compressed bytes read during cache misses, as block sized
78  		 * units.
79  		 */
80  		long readBlockBytes;
81  
82  		/** Total microseconds spent reading {@link #readBlock} blocks. */
83  		long readBlockMicros;
84  
85  		/** Total number of bytes decompressed. */
86  		long inflatedBytes;
87  
88  		Accumulator() {
89  		}
90  	}
91  
92  	private final Accumulator stats;
93  
94  	DfsReaderIoStats(Accumulator stats) {
95  		this.stats = stats;
96  	}
97  
98  	/**
99  	 * Get number of times the reader explicitly called scanPacks.
100 	 *
101 	 * @return number of times the reader explicitly called scanPacks.
102 	 */
103 	public long getScanPacks() {
104 		return stats.scanPacks;
105 	}
106 
107 	/**
108 	 * Get total number of complete pack indexes read into memory.
109 	 *
110 	 * @return total number of complete pack indexes read into memory.
111 	 */
112 	public long getReadPackIndexCount() {
113 		return stats.readIdx;
114 	}
115 
116 	/**
117 	 * Get total number of complete bitmap indexes read into memory.
118 	 *
119 	 * @return total number of complete bitmap indexes read into memory.
120 	 */
121 	public long getReadBitmapIndexCount() {
122 		return stats.readBitmap;
123 	}
124 
125 	/**
126 	 * Get total number of bytes read from indexes.
127 	 *
128 	 * @return total number of bytes read from indexes.
129 	 */
130 	public long getReadIndexBytes() {
131 		return stats.readIdxBytes;
132 	}
133 
134 	/**
135 	 * Get total microseconds spent reading pack or bitmap indexes.
136 	 *
137 	 * @return total microseconds spent reading pack or bitmap indexes.
138 	 */
139 	public long getReadIndexMicros() {
140 		return stats.readIdxMicros;
141 	}
142 
143 	/**
144 	 * Get total number of block cache hits.
145 	 *
146 	 * @return total number of block cache hits.
147 	 */
148 	public long getBlockCacheHits() {
149 		return stats.blockCacheHit;
150 	}
151 
152 	/**
153 	 * Get total number of discrete blocks actually read from pack file(s), that
154 	 * is, block cache misses.
155 	 *
156 	 * @return total number of discrete blocks read from pack file(s).
157 	 */
158 	public long getReadBlocksCount() {
159 		return stats.readBlock;
160 	}
161 
162 	/**
163 	 * Get total number of compressed bytes read during cache misses, as block
164 	 * sized units.
165 	 *
166 	 * @return total number of compressed bytes read as block sized units.
167 	 */
168 	public long getReadBlocksBytes() {
169 		return stats.readBlockBytes;
170 	}
171 
172 	/**
173 	 * Get total microseconds spent reading blocks during cache misses.
174 	 *
175 	 * @return total microseconds spent reading blocks.
176 	 */
177 	public long getReadBlocksMicros() {
178 		return stats.readBlockMicros;
179 	}
180 
181 	/**
182 	 * Get total number of bytes decompressed.
183 	 *
184 	 * @return total number of bytes decompressed.
185 	 */
186 	public long getInflatedBytes() {
187 		return stats.inflatedBytes;
188 	}
189 }