1 /* 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 17 package com.android.camera.stats.profiler; 18 19 /** 20 * A logging profile writes out all events to the provided 21 * writer and uses the standard message formatting. 22 */ 23 public class LoggingProfile extends ProfileBase { 24 private final Writer mWriter; 25 26 /** Create a new LoggingProfile */ LoggingProfile(Writer writer, String name)27 public LoggingProfile(Writer writer, String name) { 28 super(name); 29 30 mWriter = writer; 31 } 32 33 @Override onStart()34 protected void onStart() { 35 mWriter.write(format(0.0, "BEGIN")); 36 } 37 38 @Override onMark(double totalMillis, double lastMillis, String reason)39 protected void onMark(double totalMillis, double lastMillis, String reason) { 40 mWriter.write(format(totalMillis, "MARK", lastMillis, reason)); 41 } 42 43 @Override onStop(double totalMillis, double lastMillis)44 protected void onStop(double totalMillis, double lastMillis) { 45 mWriter.write(format(totalMillis, "END")); 46 } 47 48 @Override onStop(double totalMillis, double lastMillis, String reason)49 protected void onStop(double totalMillis, double lastMillis, String reason) { 50 mWriter.write(format(totalMillis, "END", lastMillis, reason)); 51 } 52 } 53