/* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.app.procstats; import static com.android.internal.app.procstats.ProcessStats.PSS_SAMPLE_COUNT; import static com.android.internal.app.procstats.ProcessStats.PSS_MINIMUM; import static com.android.internal.app.procstats.ProcessStats.PSS_AVERAGE; import static com.android.internal.app.procstats.ProcessStats.PSS_MAXIMUM; import static com.android.internal.app.procstats.ProcessStats.PSS_USS_MINIMUM; import static com.android.internal.app.procstats.ProcessStats.PSS_USS_AVERAGE; import static com.android.internal.app.procstats.ProcessStats.PSS_USS_MAXIMUM; import static com.android.internal.app.procstats.ProcessStats.PSS_COUNT; /** * Class to accumulate PSS data. */ public class PssTable extends SparseMappingTable.Table { /** * Construct the PssTable with 'tableData' as backing store * for the longs data. */ public PssTable(SparseMappingTable tableData) { super(tableData); } /** * Merge the the values from the other table into this one. */ public void mergeStats(PssTable that) { final int N = that.getKeyCount(); for (int i=0; i minPss) { setValue(key, PSS_MINIMUM, minPss); } val = getValue(key, PSS_AVERAGE); setValue(key, PSS_AVERAGE, (long)(((val*(double)count)+(avgPss*(double)inCount)) / (count+inCount))); val = getValue(key, PSS_MAXIMUM); if (val < maxPss) { setValue(key, PSS_MAXIMUM, maxPss); } val = getValue(key, PSS_USS_MINIMUM); if (val > minUss) { setValue(key, PSS_USS_MINIMUM, minUss); } val = getValue(key, PSS_USS_AVERAGE); setValue(key, PSS_USS_AVERAGE, (long)(((val*(double)count)+(avgUss*(double)inCount)) / (count+inCount))); val = getValue(key, PSS_USS_MAXIMUM); if (val < maxUss) { setValue(key, PSS_USS_MAXIMUM, maxUss); } } } }