1

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

  1. 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?

  2. 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

arefin
  • 365
  • 3
  • 17

4 Answers4

2

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.

anirvan
  • 4,797
  • 4
  • 32
  • 42
  • Thank you @anirvan.Hierachy Viewer is a tool, can I use in my Code/API? I think, I cant do this. – arefin Jul 01 '13 at 18:45
  • no. even if it were possible (assuming you find its source), i don't think the complexity would be worth the benefit. I've usually stuck to the guidelines laid out in this i/o talk — http://youtu.be/N6YdwzAvwOA — and make measurements using the HierarchyViewer. But I'll look around and share anything that might allow this in a programmatic manner. – anirvan Jul 02 '13 at 06:33
2

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;
Dan Breslau
  • 11,472
  • 2
  • 35
  • 44
  • Thank you @Dan Breslau, your idea is Awesome! – arefin Jul 01 '13 at 18:55
  • I need one more info, if you know, please let me inform. After installing apk in my device via adb command, I want to run the app automatically. No user interaction, the app will be run and navigate from one screen to other. But all screen should be reached. Any idea from you? Thanks in advance. – arefin Jul 02 '13 at 17:15
  • If I understand you right... the way that I would do this is to create a second app, that is used only by you (or other people testing your app), which contains a list of the Intents that your "real" app handles. This test app would periodically fire off one of the Intents from the list, until it reaches the end of the list, at which point it exits. I don't have time to offer more details; if you need to explore this further, I'd suggest posting a new question. – Dan Breslau Jul 02 '13 at 22:40
  • Again a Cool idea from you! , thank you again. I am going to post a new question at SO. – arefin Jul 03 '13 at 09:01
  • I have posted http://stackoverflow.com/questions/17432119/run-android-apk-in-device-without-user-interaction?noredirect=1#comment25321384_17432119 , please check if you are interested. Please let me inform if you need more info from my side. – arefin Jul 03 '13 at 09:41
0

I think (ending time - starting time) is a great solution. No point making it more complex than it is...

dors
  • 5,802
  • 8
  • 45
  • 71
0

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.

pydichandra
  • 63
  • 1
  • 1
  • 3