down votefavorite <http://stackoverflow.com/questions/39134924/how-to-instrument-android-dalvik-compiler#> I need to instrument Android 4.3 Dalvik compiler <https://android.googlesource.com/platform/dalvik/+/android-4.3.1_r1/vm/mterp/> for some purposes. *What is the goal?* The goal is to calculate the elapsed execution time used by assignment statements in the Android Dalvik VM code. *What did I do so far?* I insert the following code between assignment statement(s) in the Android Dalvik VM source code: start = get_time() <assignment statements> end = end_time() elapsed_time = end-start *Why the above code does not work?* The above code does not work for the following reasons: 1. The get_time() function, more specifically *gettimeofday()* or *clock_gettime()*, has higher resolution than the assignment statement and hence gives negative values. 2. To solve the negative values above, I end up using a for-loop to loop 1 billion times for each code that has assignment statements. However, the Android code becomes extremely slow and does not work. *What do I need to do to solve the problem?* I need to instrument the Dalvik compiler to identify the assignment instructions and calculate/estimate their execution times at the compile-time (not at run-time). Does anyone know how to do that? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/617da8a8-dcd5-4c4c-9191-01c73d1ebec3%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.