2014-01-15 3 views
2

내 Sqlite 쿼리의 성능을 최적화하려고합니다.안드로이드에서 Sqlite 쿼리의 실행 시간을 찾는 방법

각 Sqlite 문의 실행 시간을 찾을 방법이 있는지 또는 Android SDK에서 명령문 실행 시간을 볼 수있는 도구가 있는지 알고 싶습니까?

쿼리 타이머는 .timer On.timer show 명령에 익숙하지만

예 :

Query Exceution time

은 모든 대답은 정말 감사합니다!

+0

확인이 링크 http://stackoverflow.com :

즉, 이러한 로그를 인쇄를 중지하거나 장치를 다시 시작 (이 속성은 재부팅시 사이에 유지되지 않습니다) 또는 더 높은 로그 수준 속성을 설정하려면/questions/6948270/determine-execution-time-of-queries-in-sqlite 질문에 대한 답변이라고 생각합니다. –

답변

5

당신은 자바에서이 작업을 수행 할 수 있습니다 :

int startTime = System.currentTimeMillis(); 

... // Execute the query here 

int executionTime = System.currentTimeMillis() - startTime; // This variable now contains the time taken by the query, in milliseconds 
+0

@ Memmondommegav 이것은 내가 뭘 찾고 있었는지 ... thks – nitesh

1

당신은 시간을 알고 코드에서

System.currentTimeMillis(); 

를 사용할 수는 ... 쿼리를 실행에 갔다

t1=System.currentTimeMillis(); 
    //Execute query 
    t2=System.currentTimeMillis(); 

그러면 (t1-t2)는 시간차를 줄 것입니다. 일단 안드로이드 벤치마킹 앱이이 방법을 사용하여 다양한 스마트 폰이 SQL 쿼리 실행을 기반으로 수행하는 방식을 계산했습니다. 희망 하시겠습니까?

3

직접 실행 시간을 계산하는 대신 sqlite가 대신 실행하도록하십시오. here에서
: 따라서

/** 
* Controls the printing of wall-clock time taken to execute SQL statements 
* as they are executed. 
* 
* Enable using "adb shell setprop log.tag.SQLiteTime VERBOSE". 
*/ 
public static final boolean DEBUG_SQL_TIME = 
     Log.isLoggable("SQLiteTime", Log.VERBOSE); 

은, 실행을 추적 실행 시간을 사용하려면 :

adb shell setprop log.tag.SQLiteTime VERBOSE 

당신은 새로운 설정을 ** 다시로드 응용 프로그램을 다시 시작해야합니다. 오른쪽 후에는 로그 캣에서 이러한 로그 기록을보고 시작 : 27 :

12월 2일부터 14일까지을 00.457 11936-12137/I/데이터베이스 osom.info.dbtest : elapsedTime4Sql |/데이터/데이터/osom. info.dbtest/databases/test.db | 1.000 ms | 업데이트 TestTable SET 키 =? WHERE _id = 1

** 가끔은 충분하지 않으므로 adb shell stopadb shell start을 실행하십시오.

adb shell setprop log.tag.SQLiteTime ERROR 
관련 문제