Merge "improve ResearchLogger performance"

This commit is contained in:
Kurt Partridge 2012-03-29 16:14:36 -07:00 committed by Android (Google) Code Review
commit 0f55e6cbcd
2 changed files with 31 additions and 5 deletions

View file

@ -792,6 +792,19 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
super.onUpdateSelection(oldSelStart, oldSelEnd, newSelStart, newSelEnd, super.onUpdateSelection(oldSelStart, oldSelEnd, newSelStart, newSelEnd,
composingSpanStart, composingSpanEnd); composingSpanStart, composingSpanEnd);
if (ProductionFlag.IS_EXPERIMENTAL) {
if (ResearchLogger.UnsLogGroup.ON_UPDATE_SELECTION.isEnabled) {
final String s = "onUpdateSelection: oss=" + oldSelStart
+ ", ose=" + oldSelEnd
+ ", lss=" + mLastSelectionStart
+ ", lse=" + mLastSelectionEnd
+ ", nss=" + newSelStart
+ ", nse=" + newSelEnd
+ ", cs=" + composingSpanStart
+ ", ce=" + composingSpanEnd;
ResearchLogger.logUnstructured(ResearchLogger.UnsLogGroup.ON_UPDATE_SELECTION, s);
}
}
if (DEBUG) { if (DEBUG) {
Log.i(TAG, "onUpdateSelection: oss=" + oldSelStart Log.i(TAG, "onUpdateSelection: oss=" + oldSelStart
+ ", ose=" + oldSelEnd + ", ose=" + oldSelEnd

View file

@ -259,20 +259,33 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
write(LogGroup.STATE_CHANGE, subgroup + "\t" + details); write(LogGroup.STATE_CHANGE, subgroup + "\t" + details);
} }
public static enum UnsLogGroup {
// TODO: expand to include one flag per log point
// TODO: support selective enabling of flags
ON_UPDATE_SELECTION;
public boolean isEnabled = true;
}
public static void logUnstructured(UnsLogGroup logGroup, String details) {
}
private void write(final LogGroup logGroup, final String log) { private void write(final LogGroup logGroup, final String log) {
// TODO: rewrite in native for better performance
mLoggingHandler.post(new Runnable() { mLoggingHandler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
final long currentTime = System.currentTimeMillis(); final long currentTime = System.currentTimeMillis();
mDate.setTime(currentTime);
final long upTime = SystemClock.uptimeMillis(); final long upTime = SystemClock.uptimeMillis();
final StringBuilder builder = new StringBuilder();
final String printString = String.format("%s\t%d\t%s\t%s\n", builder.append(currentTime);
mDateFormat.format(mDate), upTime, logGroup.mLogString, log); builder.append('\t'); builder.append(upTime);
builder.append('\t'); builder.append(logGroup.mLogString);
builder.append('\t'); builder.append(log);
if (LatinImeLogger.sDBG) { if (LatinImeLogger.sDBG) {
Log.d(TAG, "Write: " + '[' + logGroup.mLogString + ']' + log); Log.d(TAG, "Write: " + '[' + logGroup.mLogString + ']' + log);
} }
if (mLogFileManager.append(printString)) { if (mLogFileManager.append(builder.toString())) {
// success // success
} else { } else {
if (LatinImeLogger.sDBG) { if (LatinImeLogger.sDBG) {