Reputation: 365
I am trying to develop an API for Android platform to measure the app performance. For example, I need the following things to measure of an android app. I need Expert suggestion
How much time app is taking to login? Login via back end system. User name and password is saved in database server and android app will check user name and password from database server. How much time app is taking to check? One common solution for this: starting time and ending time of user name/password checking function, then (ending time - starting time) will give the actual time which app needed to be login check. Any other suggestion from Expert?
Calculate the rendering time it takes for all these UI components (TextView,ImageView etc) to load successfully. ImageView image will be load from server. Need suggestion from Expert also. I can apply #1 ticks here, but like to hear from Experts :)
Thanks Arefin
Upvotes: 1
Views: 497
Reputation: 63
Can you take a look at: https://firebase.google.com/docs/perf-mon/get-started-android?
You can use either custom traces to measure performance of piece of code (by adding Trace.start(), Trace.stop() around that code) or use @AddTrace annotation to trace specific methods.
Once enabled, Firebase performance automatically measures App start time and network requests latency, request/response size etc.
Upvotes: 0
Reputation: 11522
If you're concerned about local CPU usage, then don't use wall clock time (i.e., the time that would be shown by a clock on your wall). Android includes a Debug class with a static method, threadCpuTimeNanos() that would be much more appropriate for that purpose:
long startTime = Debug.threadCpuTimeNanos();
// your computation goes here
long endTime = Debug.threadCpuTimeNanos();
// If this comes out as 0, you probably don't need to worry about performance :-)
long cpuTimeInMilliseconds = (endTime - startTime) / 1000000;
Upvotes: 2
Reputation: 4877
To measure your app's performance, it's a fair choice to make use of a simple Stopwatch
kind of utility. Or you could also make use of a standard tool like Android's traceview.
However, if you'd like to see how your app is performing amongst your users, then a solution like New Relic can come in very handy. It allows you to measure your app's performance for various HTTP requests.
Finally, to track how your app is performing when it comes to rendering objects, then it's best to use Android's very own Hierarchy Viewer.
Upvotes: 2
Reputation: 5892
I think (ending time - starting time) is a great solution. No point making it more complex than it is...
Upvotes: 0