EMMA Coverage Report (generated Fri Aug 23 16:39:17 PDT 2013)
[all classes][org.chromium.content.browser]

COVERAGE SUMMARY FOR SOURCE FILE [HeapStatsLogger.java]

nameclass, %method, %block, %line, %
HeapStatsLogger.java25%  (1/4)12%  (1/8)5%   (5/111)10%  (2/20)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class HeapStatsLogger$10%   (0/1)100% (0/0)100% (0/0)100% (0/0)
     
class HeapStatsLogger$HeapStatsLoggerIntentFilter0%   (0/1)0%   (0/1)0%   (0/6)0%   (0/3)
HeapStatsLogger$HeapStatsLoggerIntentFilter (): void 0%   (0/1)0%   (0/6)0%   (0/3)
     
class HeapStatsLogger$HeapStatsLoggerReceiver0%   (0/1)0%   (0/3)0%   (0/31)0%   (0/5)
HeapStatsLogger$HeapStatsLoggerReceiver (HeapStatsLogger): void 0%   (0/1)0%   (0/6)0%   (0/1)
HeapStatsLogger$HeapStatsLoggerReceiver (HeapStatsLogger, HeapStatsLogger$1):... 0%   (0/1)0%   (0/4)0%   (0/1)
onReceive (Context, Intent): void 0%   (0/1)0%   (0/21)0%   (0/4)
     
class HeapStatsLogger100% (1/1)25%  (1/4)7%   (5/74)17%  (2/12)
HeapStatsLogger (Context): void 0%   (0/1)0%   (0/23)0%   (0/6)
access$100 (HeapStatsLogger): void 0%   (0/1)0%   (0/3)0%   (0/1)
log (): void 0%   (0/1)0%   (0/38)0%   (0/2)
init (Context): void 100% (1/1)50%  (5/10)67%  (2/3)

1// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4 
5package org.chromium.content.browser;
6 
7import android.content.BroadcastReceiver;
8import android.content.Context;
9import android.content.Intent;
10import android.content.IntentFilter;
11import android.os.Debug;
12import android.util.Log;
13 
14import org.chromium.content.common.CommandLine;
15 
16// Logs Heap stats, such as gc count, alloc count, etc.
17// It's enabled by CommandLine.ENABLE_TEST_INTENTS, and logs whenever broadcast
18// intent ACTION_LOG is received, e.g.:
19// adb shell am broadcast -a com.google.android.apps.chrome.LOG_HEAP_STATS
20public class HeapStatsLogger {
21    private static final String TAG = "HeapStatsLogger";
22    private static final String ACTION_LOG = "com.google.android.apps.chrome.LOG_HEAP_STATS";
23 
24    private static HeapStatsLogger sHeapStats;
25 
26    private HeapStatsLoggerReceiver mBroadcastReceiver;
27    private HeapStatsLoggerIntentFilter mIntentFilter;
28 
29    public static void init(Context context) {
30        if (CommandLine.getInstance().hasSwitch(CommandLine.ENABLE_TEST_INTENTS)) {
31            sHeapStats = new HeapStatsLogger(context);
32        }
33    }
34 
35    private HeapStatsLogger(Context context) {
36        Debug.startAllocCounting();
37        mBroadcastReceiver = new HeapStatsLoggerReceiver();
38        mIntentFilter = new HeapStatsLoggerIntentFilter();
39        context.registerReceiver(mBroadcastReceiver, mIntentFilter);
40    }
41 
42    private static class HeapStatsLoggerIntentFilter extends IntentFilter {
43        HeapStatsLoggerIntentFilter() {
44            addAction(ACTION_LOG);
45        }
46    }
47 
48    private class HeapStatsLoggerReceiver extends BroadcastReceiver {
49        @Override
50        public void onReceive(Context context, Intent intent) {
51            if (ACTION_LOG.equals(intent.getAction())) {
52                log();
53            } else {
54                Log.e(TAG, "Unexpected intent: " + intent);
55            }
56        }
57    }
58 
59    private void log() {
60        Log.i(TAG, "heap_stats " +
61              // Format is "key=value unit", and it'll be parsed by the test
62              // runner in order to be added to the bot graphs.
63              "gc_count=" + Debug.getGlobalGcInvocationCount() + " times " +
64              "alloc_count=" + Debug.getGlobalAllocCount() + " times " +
65              "alloc_size=" + Debug.getGlobalAllocSize() + " bytes " +
66              "freed_count=" + Debug.getGlobalFreedCount() + " times " +
67              "freed_size=" + Debug.getGlobalFreedSize() + " bytes"
68        );
69    }
70}

[all classes][org.chromium.content.browser]
EMMA 2.0.5312 (C) Vladimir Roubtsov