How to find total number instructions of a program? - android

I want to find the total number of machine instructions of an Android Application. I have explored the Debug.InstructionCount class of Android SDK, but I believe it provides info of Dalvik VM instructions (not the machine level instructions which actually executes on the processor).
I need this info to estimate the time required for the execution of an Android application on a particular processor (using fixed frequency). I am aware of the fact that different type of instructions take variable cycles due to which the computational time cannot be estimated accurately, but I still want to do some experimentation. Thank you

My solution involves writing an instruction set simulator, running the app and counting the instructions. There are already open source avr simulators out there than you can just use/modify for this.
At the end of the day in order to do this you have to follow the instruction flow, so either you actually sim it and that automatically solves how many times the code really goes through a loop and such, or you write a disassembler (which is half of a simulator) and basically follow the code flow in execution order (actually much simpler than a full disassembler or simulator) but you have to deal with all the possible code paths and loops as you find the different paths and count the different paths. With minimal work you could come up with the shortest possible path and know the code could never be faster than that.

Related

Android Monitor Graph logs

I have a simple application that contains two implementations which I want to compare(benchmark) with each other in terms of usage during a certain amount of time.
The testing method is equal for both implementations (they both execute exactly the same commands/events) the only difference is the way they process the command and events.
I wish to get a log per second of:
CPU load
Memory usage
Network traffic
The Android Monitor provides everything I need in a graph and logs per second the current CPU load, Memory usage and the TX/RX for network traffic, great!
However I wish to have this all in a text log instead of a live graph. Can someone tell me where I could find such a log? OR if there is no such thing, any suggestions to get similar data?
Doppie, I looked for a solution using out-of-box tools, but there is no good way to use the Android tools to export just the information you want to a text file without lots of work. Logcat is way too verbose and requires conversion, and Dalvik doesn't exactly provide you the every-second control over data collection. I would love to have a simple solution for this too. :/
[Disclaimer: Because I work with Perfecto, I know that the devices in their cloud lab can do this easily, so if you are trying to diagnose a specific problem, you could use their free public cloud and export the device vitals (shown below). This is not a pitch, but since it's free to play, it might help you in the short-term.]
hi first of all if you looking for memory logs. There is one option you can directly go and check that one.
Open Android Device Monitor then checks heap dumps.Check the uses of memory.
Another way to monitor Android Device Monitor then see the Allocation Tracker it gives you details in everyclass where you memory is used.
Expect these things you can directly check your Current logs.
Click Android Monitor and see logcat and second option Monitors.
Monitors gives you Four type of details :
1. Memory usages.
2. CPU how kuch usages of your phone.
3. Network
4. GPU.
Now after these all things. If you still have some problem then need to check your gradle.
What kind of libraries you used.
First of all remove unwanted libraries.
Secondly need to import only useful libraries. Like if you looking for map related things in your app then import only.
compile "com.google.android.gms:play-services-maps:9.4.0"
not this one.
compile 'com.google.android.gms:play-services:9.4.0'
Aware about replication of libraries.
Example : If you using some libraries and that libaray contain appcompt and you are also using same libaray in your app side.Then its better to use that libaray as module.
At last try to use proguard rules.
These are few ways to handle better memory management.
I have made one android app architecture here is link..
Thanks hope this will help you.

Android: can c++ code be aware of Android app memory use?

I have been searching for this answer for days and can't find a straightforward answer. I am working on an application written in C++ and that has been ported to Android. I am able to launch and run without too much hassle. My task is to figure out how much RAM our app is using dynamically so that we can handle memory issues dynamically-- which in my mind means that I need to have something in my C++ that can somehow be aware of system characteristics. What I have been able to do, is in my Java code, I can pull certain metrics that belong to my app via the getMemoryInfo call. Like in this post: Programmatically find Android system info
However, I would really like to be able to probe this from our C++ code so that we can handle everything in there...
Is this even possible?
If it is, are the calls unrealistically expensive?
If it is not, how is it possible to manage your memory through the native code rather than the Java code? i.e. If I see that I only have x amount of RAM available, I can dynamically change how much memory I want allocated to something in my C++ code to accommodate what the system has to offer.
Something along the lines of:
Ex. C++ Code:
if (android.os.thisApp.RAM left < 20 )
allocate 10M
else
allocate 20M

How to get the read and write speed of android RAM?

I need to test the performance of android's ram. How can I get the read and write speed of android RAM.
Since I have root authority and busybox, the method can be a bash shell or an android app.
Thanks.
You will need to write your own benchmark, or look up the statistics on benchmark providers such as PassMask Android. Benchmark writing involves a lot of methodologies (rules to be followed to get a correct, meaningful, and reproducible result.)
Measure memory speed doing what? It depends on what instructions are handling the data and whether the access is sequential or random (or backwards). It can also vary with multithreading using one or multiple cores. The following has results of my three Android memory benchmarks (and links to MP results). These might help in deciding what to do.
http://www.roylongbottom.org.uk/android%20benchmarks.htm#anchorStart

Android performance meter

I looking a tools that can be helps for me to measure my performance in some parts of code in my android application.
Is there any tools for help me?
Now i was written a class that measure my functions in app, but may be is exist more effective methods?
I'm not sure if you are looking for a tool to instrument your code and review your stack trace execution time or something more related to different metrics, but maybe I can help. I'm working on a tool we will release soon, this tool will allow us to monitor our application performance in production using real-time stats. The platform is named FlowUp http://flowup.io/. Just adding an Android library to your project you could monitor your application in production in real-time :)
Using FLowUp you can get information about your application performance in terms of:
Frame time.
Frames per second.
Network consumption.
CPU usage.
Disk usage.
Memory consumption in terms of load and bytes allocated.
And much more metrics. Of course, all these metrics can be reviewed crossing this information with some tags related to the application or the device. For example, you could get information about the network consumption or the frames per second of your app per activity and comparing different app or Android OS version.
This is an screenshot I've taken from our landing page:
Right now we are under development but I recommend you to subscribe to our mail list in http://flowup.io to have access to the first beta we will release soon :)
If you have any metric you'd really like to monitor, please don't hesitate to request it! Maybe we can implement this for you :)
Sure there are tools for that. Try this: Android Systrace.

Can an app be monitored for security?

A coworker and I were talking (after a fashion) about an article I read (HTC permission security risk). Basically, the argument came down to whether or not it was possible to log every action that an application was doing. Then someone (an abstract theroetical person) would go through and see if the app was doing what it was supposed to do and not trying to be all malicious like.
I have been programming in Android for a year now, and as far as I know if -- if -- that was possible, you would have to hack Dalvik and output what each process was doing. Even if you were to do that, I think it would be completely indecipherable because of the sheer amount of stuff each process was doing.
Can I get some input one way or the other? Is it completely impractical to even attempt to log what a foriegn application is doing?
I have been programming in Android for a year now, and as far as I know if -- if -- that was possible, you would have to hack Dalvik and output what each process was doing.
Not so much "hack Dalvik" but "hack the android.* class library, and perhaps a few other things (e.g., java.net).
Even if you were to do that, I think it would be completely indecipherable because of the sheer amount of stuff each process was doing.
You might be able to do some fancy pattern matching or something on the output -- given that you have determined patterns of inappropriate actions. Of course, there is also the small matter of having to manually test the app (to generate the output).
Is it completely impractical to even attempt to log what a foriegn application is doing?
From an SDK app? I damn well hope so.
From a device running a modded firmware with the aforementioned changes? I'd say it is impractical unless you have a fairly decent-sized development team, at which point it is merely expensive.
This is both possible and practical if you are compiling your own ROM. Android is based on Linux and I know several projects like this for Linux, like Linux Trace Toolkit. I also know of research into visualizing the results and detecting malicious apps from the results as well.
Another thing functionality like this is often used for is performance and reliability monitoring. You can read about the DTRACE functionality in Solaris to learn more about how this sort of stuff is used in business rather than academia.

Categories

Resources