Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9709fa26 authored by Stefan Lafon's avatar Stefan Lafon
Browse files

Track PSS in loadtest.

Test: Ran the loadtest. Not changing statsd.

Change-Id: Idc43cba59ec2c9d4213e20b395a083fdda58e8c4
parent 05708745
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -39,5 +39,6 @@
    </activity>
    <receiver android:name=".LoadtestActivity$PusherAlarmReceiver" />
    <receiver android:name=".LoadtestActivity$StopperAlarmReceiver"/>
    <receiver android:name=".PerfData$PerfAlarmReceiver"/>
  </application>
</manifest>
+1 −6
Original line number Diff line number Diff line
@@ -166,12 +166,6 @@
            android:layout_height="wrap_content"
            android:text="@string/display_output"
            android:textSize="30dp"/>
        <Button
            android:id="@+id/display_perf"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/display_perf"
            android:textSize="30dp"/>

        <Space
            android:layout_width="1dp"
@@ -179,6 +173,7 @@

        <TextView
            android:id="@+id/report_text"
            android:gravity="center"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

+0 −1
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@
    <string name="bucket_label">bucket size (mins):&#160;</string>
    <string name="burst_label">burst:&#160;</string>
    <string name="display_output">Show metrics data</string>
    <string name="display_perf">Show perf data</string>
    <string name="placebo">placebo</string>
    <string name="period_label">logging period (secs):&#160;</string>
    <string name="replication_label">metric replication:&#160;</string>
+53 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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.statsd.loadtest;

import android.annotation.Nullable;
import android.content.Context;
import android.util.Log;
import java.text.ParseException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class BatteryDataRecorder extends PerfDataRecorder {
    private static final String TAG = "loadtest.BatteryDataRecorder";
    private static final String DUMP_FILENAME = TAG + "_dump.tmp";

    public BatteryDataRecorder(boolean placebo, int replication, long bucketMins, long periodSecs,
        int burst) {
        super(placebo, replication, bucketMins, periodSecs, burst);
    }

    @Override
    public void startRecording(Context context) {
        // Reset batterystats.
        runDumpsysStats(context, DUMP_FILENAME, "batterystats", "--reset");
    }

    @Override
    public void onAlarm(Context context) {
        // Nothing to do as for battery, the whole data is in the final dumpsys call.
    }

    @Override
    public void stopRecording(Context context) {
        StringBuilder sb = new StringBuilder();
        // Don't use --checkin.
        runDumpsysStats(context, DUMP_FILENAME, "batterystats");
        readDumpData(context, DUMP_FILENAME, new BatteryStatsParser(), sb);
        writeData(context, "battery_", "time,battery_level", sb);
    }
}
+3 −2
Original line number Diff line number Diff line
@@ -21,13 +21,13 @@ import java.text.ParseException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class BatteryStatsParser {
public class BatteryStatsParser implements PerfParser {

    private static final Pattern LINE_PATTERN =
        Pattern.compile("\\s*\\+*(\\S*)\\s\\(\\d+\\)\\s(\\d\\d\\d)\\s.*");
    private static final Pattern TIME_PATTERN =
        Pattern.compile("(\\d+)?(h)?(\\d+)?(m)?(\\d+)?(s)?(\\d+)?(ms)?");
    private static final String TAG = "BatteryStatsParser";
    private static final String TAG = "loadtest.BatteryStatsParser";

    private boolean mHistoryStarted;
    private boolean mHistoryEnded;
@@ -35,6 +35,7 @@ public class BatteryStatsParser {
    public BatteryStatsParser() {
    }

    @Override
    @Nullable
    public String parseLine(String line) {
        if (mHistoryEnded) {
Loading