8000 Remove logTimeStat · boxer/android-database-sqlcipher@33e3d96 · GitHub
[go: up one dir, main page]

Skip to content

Commit 33e3d96

Browse files
Remove logTimeStat
1 parent 85ff898 commit 33e3d96

File tree

3 files changed

+0
-91
lines changed

3 files changed

+0
-91
lines changed

src/net/sqlcipher/database/SQLiteDatabase.java

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import java.util.Iterator;
4141
import java.util.Locale;
4242
import java.util.Map;
43-
import java.util.Random;
4443
import java.util.Set;
4544
import java.util.WeakHashMap;
4645
import java.util.concurrent.locks.ReentrantLock;
@@ -368,7 +367,6 @@ public static synchronized void loadLibs (Context context, File workingDir) {
368367
private static int sQueryLogTimeInMillis = 0; // lazily initialized
369368
private static final int QUERY_LOG_SQL_LENGTH = 64;
370369
private static final String COMMIT_SQL = "COMMIT;";
371-
private final Random mRandom = new Random();
372370
private String mLastSqlStatement = null;
373371

374372
// String prefix for slow database query EventLog records that show
@@ -2181,7 +2179,6 @@ public void execSQL(String sql) throws SQLException {
21812179
if (!isOpen()) {
21822180
throw new IllegalStateException("database not open");
21832181
}
2184-
logTimeStat(mLastSqlStatement, timeStart, GET_LOCK_LOG_PREFIX);
21852182
try {
21862183
native_execSQL(sql);
21872184
} catch (SQLiteDatabaseCorruptException e) {
@@ -2190,15 +2187,6 @@ public void execSQL(String sql) throws SQLException {
21902187
} finally {
21912188
unlock();
21922189
}
2193-
2194-
// Log commit statements along with the most recently executed
2195-
// SQL statement for disambiguation. Note that instance
2196-
// equality to COMMIT_SQL is safe here.
2197-
if (sql == COMMIT_SQL) {
2198-
logTimeStat(mLastSqlStatement, timeStart, COMMIT_SQL);
2199-
} else {
2200-
logTimeStat(sql, timeStart, null);
2201-
}
22022190
}
22032191

22042192
public void rawExecSQL(String sql){
@@ -2207,7 +2195,6 @@ public void rawExecSQL(String sql){
22072195
if (!isOpen()) {
22082196
throw new IllegalStateException("database not open");
22092197
}
2210-
logTimeStat(mLastSqlStatement, timeStart, GET_LOCK_LOG_PREFIX);
22112198
try {
22122199
native_rawExecSQL(sql);
22132200
} catch (SQLiteDatabaseCorruptException e) {
@@ -2216,15 +2203,6 @@ public void rawExecSQL(String sql){
22162203
} finally {
22172204
unlock();
22182205
}
2219-
2220-
// Log commit statements along with the most recently executed
2221-
// SQL statement for disambiguation. Note that instance
2222-
// equality to COMMIT_SQL is safe here.
2223-
if (sql == COMMIT_SQL) {
2224-
logTimeStat(mLastSqlStatement, timeStart, COMMIT_SQL);
2225-
} else {
2226-
logTimeStat(sql, timeStart, null);
2227-
}
22282206
}
22292207

22302208
/**
@@ -2266,7 +2244,6 @@ public void execSQL(String sql, Object[] bindArgs) throws SQLException {
22662244
}
22672245
unlock();
22682246
}
2269-
logTimeStat(sql, timeStart);
22702247
}
22712248

22722249
@Override
@@ -2469,67 +2446,6 @@ public final String getPath() {
24692446
return mPath;
24702447
}
24712448

2472-
/* package */ void logTimeStat(String sql, long beginMillis) {
2473-
logTimeStat(sql, beginMillis, null);
2474-
}
2475-
2476-
/* package */ void logTimeStat(String sql, long beginMillis, String prefix) {
2477-
// Keep track of the last statement executed here, as this is
2478-
// the common funnel through which all methods of hitting
2479-
// libsqlite eventually flow.
2480-
mLastSqlStatement = sql;
2481-
2482-
// Sample fast queries in proportion to the time taken.
2483-
// Quantize the % first, so the logged sampling probability
2484-
// exactly equals the actual sampling rate for this query.
2485-
2486-
int samplePercent;
2487-
long durationMillis = SystemClock.uptimeMillis() - beginMillis;
2488-
if (durationMillis == 0 && prefix == GET_LOCK_LOG_PREFIX) {
2489-
// The common case is locks being uncontended. Don't log those,
2490-
// even at 1%, which is our default below.
2491-
return;
2492-
}
2493-
if (sQueryLogTimeInMillis == 0) {
2494-
sQueryLogTimeInMillis = 500;//SystemProperties.getInt("db.db_operation.threshold_ms", 500);
2495-
}
2496-
if (durationMillis >= sQueryLogTimeInMillis) {
2497-
samplePercent = 100;
2498-
} else {;
2499-
samplePercent = (int) (100 * durationMillis / sQueryLogTimeInMillis) + 1;
2500-
if (mRandom.nextInt(100) >= samplePercent) return;
2501-
}
2502-
2503-
// Note: the prefix will be "COMMIT;" or "GETLOCK:" when non-null. We wait to do
2504-
// it here so we avoid allocating in the common case.
2505-
if (prefix != null) {
2506-
sql = prefix + sql;
2507-
}
2508-
2509-
if (sql.length() > QUERY_LOG_SQL_LENGTH) sql = sql.substring(0, QUERY_LOG_SQL_LENGTH);
2510-
2511-
// ActivityThread.currentPackageName() only returns non-null if the
2512-
// current thread is an application main thread. This parameter tells
2513-
// us whether an event loop is blocked, and if so, which app it is.
2514-
//
2515-
// Sadly, there's no fast way to determine app name if this is *not* a
2516-
// main thread, or when we are invoked via Binder (e.g. ContentProvider).
2517-
// Hopefully the full path to the database will be informative enough.
2518-
2519-
//TODO get the current package name
2520-
String blockingPackage = "unknown";//ActivityThread.currentPackageName();
2521-
if (blockingPackage == null) blockingPackage = "";
2522-
2523-
/*
2524-
EventLog.writeEvent(
2525-
EVENT_DB_OPERATION,
2526-
getPathForLogs(),
2527-
sql,
2528-
durationMillis,
2529-
blockingPackage,
2530-
samplePercent);*/
2531-
}
2532-
25332449
/**
25342450
* Removes email addresses from database filenames before they're
25352451
* logged to the EventLog where otherwise apps could potentially

src/net/sqlcipher/database/SQLiteQuery.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ public class SQLiteQuery extends SQLiteProgram {
6262
int maxRead, int lastPos) {
6363
long timeStart = SystemClock.uptimeMillis();
6464
mDatabase.lock();
65-
mDatabase.logTimeStat(mSql, timeStart, SQLiteDatabase.GET_LOCK_LOG_PREFIX);
6665
try {
6766
acquireReference();
6867
try {
@@ -77,7 +76,6 @@ public class SQLiteQuery extends SQLiteProgram {
7776
if (SQLiteDebug.DEBUG_SQL_STATEMENTS) {
7877
Log.d(TAG, "fillWindow(): " + mSql);
7978
}
80-
mDatabase.logTimeStat(mSql, timeStart);
8179
return numRows;
8280
} catch (IllegalStateException e){
8381
// simply ignore it

src/net/sqlcipher/database/SQLiteStatement.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public void execute() {
5656
acquireReference();
5757
try {
5858
native_execute();
59-
mDatabase.logTimeStat(mSql, timeStart);
6059
} finally {
6160
releaseReference();
6261
mDatabase.unlock();
@@ -82,7 +81,6 @@ public long executeInsert() {
8281
acquireReference();
8382
try {
8483
native_execute();
85-
mDatabase.logTimeStat(mSql, timeStart);
8684
return (mDatabase.lastChangeCount() > 0) ? mDatabase.lastInsertRow() : -1;
8785
} finally {
8886
releaseReference();
@@ -100,7 +98,6 @@ public int executeUpdateDelete() {
10098
acquireReference();
10199
try {
102100
native_execute();
103-
mDatabase.logTimeStat(mSql, timeStart);
104101
return mDatabase.lastChangeCount();
105102
} finally {
106103
releaseReference();
@@ -126,7 +123,6 @@ public long simpleQueryForLong() {
126123
acquireReference();
127124
try {
128125
long retValue = native_1x1_long();
129-
mDatabase.logTimeStat(mSql, timeStart);
130126
return retValue;
131127
} finally {
132128
releaseReference();
@@ -152,7 +148,6 @@ public String simpleQueryForString() {
152148
acquireReference();
153149
try {
154150
String retValue = native_1x1_string();
155-
mDatabase.logTimeStat(mSql, timeStart);
156151
return retValue;
157152
} finally {
158153
releaseReference();

0 commit comments

Comments
 (0)
0