From 347fcab043f4822cbe182ea9ec9c0237a9101fb5 Mon Sep 17 00:00:00 2001 From: Kurt Partridge Date: Thu, 29 Mar 2012 12:20:01 -0700 Subject: [PATCH] improve ResearchLogger performance also demonstrate proposed logpoint invocation Bug: 6188932 Change-Id: Ib6a7a196fe2e5f8184d26d1e0e3e91b404454112 --- .../android/inputmethod/latin/LatinIME.java | 13 +++++++++++ .../inputmethod/latin/ResearchLogger.java | 23 +++++++++++++++---- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index e6094d9e1..8b32be937 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -792,6 +792,19 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar super.onUpdateSelection(oldSelStart, oldSelEnd, newSelStart, newSelEnd, 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) { Log.i(TAG, "onUpdateSelection: oss=" + oldSelStart + ", ose=" + oldSelEnd diff --git a/java/src/com/android/inputmethod/latin/ResearchLogger.java b/java/src/com/android/inputmethod/latin/ResearchLogger.java index 570333cb7..c5fb61f78 100644 --- a/java/src/com/android/inputmethod/latin/ResearchLogger.java +++ b/java/src/com/android/inputmethod/latin/ResearchLogger.java @@ -259,20 +259,33 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang 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) { + // TODO: rewrite in native for better performance mLoggingHandler.post(new Runnable() { @Override public void run() { final long currentTime = System.currentTimeMillis(); - mDate.setTime(currentTime); final long upTime = SystemClock.uptimeMillis(); - - final String printString = String.format("%s\t%d\t%s\t%s\n", - mDateFormat.format(mDate), upTime, logGroup.mLogString, log); + final StringBuilder builder = new StringBuilder(); + builder.append(currentTime); + builder.append('\t'); builder.append(upTime); + builder.append('\t'); builder.append(logGroup.mLogString); + builder.append('\t'); builder.append(log); if (LatinImeLogger.sDBG) { Log.d(TAG, "Write: " + '[' + logGroup.mLogString + ']' + log); } - if (mLogFileManager.append(printString)) { + if (mLogFileManager.append(builder.toString())) { // success } else { if (LatinImeLogger.sDBG) {