blob: 6e6c3235cef0291a638d180b4971a257d14ff06c [file] [log] [blame]
Richard Uhlerb730b782015-07-15 16:01:58 -07001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.ahat;
18
19import com.android.tools.perflib.heap.Heap;
20import java.io.IOException;
21import java.io.File;
22import java.util.Collections;
23import java.util.List;
24
25class OverviewHandler extends AhatHandler {
26 private File mHprof;
27
28 public OverviewHandler(AhatSnapshot snapshot, File hprof) {
29 super(snapshot);
30 mHprof = hprof;
31 }
32
33 @Override
34 public void handle(Doc doc, Query query) throws IOException {
35 doc.title("Overview");
36
37 doc.section("General Information");
38 doc.descriptions();
39 doc.description(
40 DocString.text("ahat version"),
41 DocString.text("ahat-%s", OverviewHandler.class.getPackage().getImplementationVersion()));
42 doc.description(DocString.text("hprof file"), DocString.text(mHprof.toString()));
43 doc.end();
44
45 doc.section("Heap Sizes");
46 printHeapSizes(doc);
47
48 DocString menu = new DocString();
49 menu.appendLink(DocString.uri("roots"), DocString.text("Roots"));
50 menu.append(" - ");
51 menu.appendLink(DocString.uri("site"), DocString.text("Allocations"));
52 menu.append(" - ");
53 menu.appendLink(DocString.uri("help"), DocString.text("Help"));
54 doc.big(menu);
55 }
56
57 private void printHeapSizes(Doc doc) {
58 List<Object> dummy = Collections.singletonList(null);
59
60 HeapTable.TableConfig<Object> table = new HeapTable.TableConfig<Object>() {
61 public String getHeapsDescription() {
62 return "Bytes Retained by Heap";
63 }
64
65 public long getSize(Object element, Heap heap) {
66 return mSnapshot.getHeapSize(heap);
67 }
68
69 public List<HeapTable.ValueConfig<Object>> getValueConfigs() {
70 return Collections.emptyList();
71 }
72 };
73 HeapTable.render(doc, table, mSnapshot, dummy);
74 }
75}
76