improve ResearchLogger performance
also demonstrate proposed logpoint invocation Bug: 6188932 Change-Id: Ib6a7a196fe2e5f8184d26d1e0e3e91b404454112
This commit is contained in:
parent
8acbce1f78
commit
347fcab043
2 changed files with 31 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue