Search code examples
androidperformanceandroid-sqlite

how to find out the execution time of Sqlite query in android


I'm trying to optimize the performance of my Sqlite queries.

I wanted to know if there is any way to find the execution time of each Sqlite statement, or if there is any tool that allows to view the statement execution time in Android SDK?

Although I'm familiar with .timer On and .timer show commands for Query timer.

Example:

Query Exceution time

Any answer is truly appreciated!


Solution

  • You could do this in Java:

    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