01: package org.apache.lucene.benchmark.stats;
02:
03: /**
04: * Copyright 2005 The Apache Software Foundation
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: /**
20: * This class holds a set of memory usage values.
21: *
22: * @author Andrzej Bialecki <ab@getopt.org>
23: */
24: public class MemUsage {
25: public long maxFree, minFree, avgFree;
26:
27: public long maxTotal, minTotal, avgTotal;
28:
29: public String toString() {
30: return toScaledString(1, "B");
31: }
32:
33: /** Scale down the values by divisor, append the unit string. */
34: public String toScaledString(int div, String unit) {
35: StringBuffer sb = new StringBuffer();
36: sb.append("free=").append(minFree / div);
37: sb.append("/").append(avgFree / div);
38: sb.append("/").append(maxFree / div).append(" ").append(unit);
39: sb.append(", total=").append(minTotal / div);
40: sb.append("/").append(avgTotal / div);
41: sb.append("/").append(maxTotal / div).append(" ").append(unit);
42: return sb.toString();
43: }
44: }
|