Android executes codes faster than PC - android

The same code for Android (1Ghz Snapdragon) executes 2 time faster, than on my PC (in desktop application) with 3.3 Ghz Core 2 Duo (class from PC was copied to Android project). Tested with Win7 and Debian. Time mesured by System.currentTimeMillis() for only one (main) calculating method. Why it's happend and what can I do to fix it?
UPD1. First application running on real android device, second - in JRE
UPD2. In that part of applications, that I try to compare, used only simple math and operations with BigDecimal (multiply, sqrt, divide and so on). Idea - calculate pi by gauss-legendre algorithm

You're going to need to be more specific about what you're doing to monitor this. There are a large number of factors at play that could influence this. If you're running on the emulator, forget it -- it's incredibly slow, there's really no comparison there. However, I get the feeling you're talking about one application running in the JVM as a standard Java application and another application running on Dalvik, but there, you really can't compare either. Different frameworks have different libraries and different calls that are implemented in different ways. Not to mention Dalvik is optimized differently than the standard JVM and so on.
You'll need to give us more information in order for us to attempt to give you an explanation, but I suspect you're trying to compare two things that really can't be compared.

I think because the Android device has a different processor architecture than your PC, so the CPU on your PC needs to emulate the Android, so it would do much more processing.

Related

What is the difference between make and mka?

So I'm building TWRP. I see that some use the command make when building the recovery image, e.g. make -j5 recoveryimage, but others use mka recoveryimage.
What is the difference between the two commands make and mka? I couldn't find a comprehensive answer on my own.
Thanks!
mka is intended to be a faster make. Here's a nice description (source):
This little gem of a command is basically equivalent to a super-charged version of make. Make is the program that gets called to build our source, choosing the correct compiler for each part of the Android OS that we are making. Problem is, make is SLOW in its default configuration. It can take hours longer depending on your hardware. So what did they do? They mated make with a cheetah, and took their child mka. mka improves upon make by using the program sched_tool to make full use of all the threads available on your machine (For AMD, this is equivalent to the number of cores your processor has; For Intel, this is usually equivalent to twice the number of cores your processor has, due to HyperThreading). What this means is that ALL of your processor is working, not just one small part of it.

GPGPU Android Emulator (Renderscript / OpenCL)

More specifically, I'm wanting to run OpenCL / Renderscript code in an Android Emulator that actually runs on my computer's GPU instead of CPU. Unluckily I'm using an AMD CPU and GPU.
I know that AMD has OpenGL ES support (and everything supports OpenCL pretty much) via SDKs but that's as far as I've gotten on that front - the only OpenCL / Renderscript information I've found regarding emulators is that they either don't work at all or, if I had an Intel CPU, I could install OpenCL in the emulator but it would only use the CPU (and frankly I wouldn't be surprised if behind the scenes my emulator(s) aren't already doing this - OpenCV runs without incident but OpenCL-Z says there's no OpenCL support).
Is there some way to send the commands from the emulator to my OS and have it automatically run? The only ways I've come up with involve saving and loading a text file which isn't likely to be faster (or good for my hard drive) given I'm running 2 Emulator Instances.
I found some mention of RenderScript being supported in the official emulator but said emulator isn't meant for my use-case and I strongly doubt that it's going to use my GPU.
I'm using Memu at the moment because Bluestacks 3 uses more resources when running 2 instances and the 2nd instance doesn't work very well with adb commands / root for some reason - it thinks it's working but it doesn't do anything. If there's a faster emulator when it comes to running 2 instances I'm sure it would help but oddly enough comparing them is difficult and time consuming (especially when every one of them is like "No, I'M the fastest - look at MY bar graphs!" lol) and ultimately I believe my problem to be with OpenCV not getting GPU acceleration (because it runs much faster on my phone) and not the emulator's base speed.
I have AMD's virtualization features enabled (confirmed with Leomoon or w/e) and they're enabled in the manager for Memu. Perhaps this is already working behind the scenes, then? Either way, emulation costs increase by 10% per instance once the OpenCV stuff comes into play (taking it from 60 to 80%+)
Use a language (like Python) and send commands via ADB. Python can hook into OpenCL and OpenCV; ADB can be used to get the Framebuffer for screenshots or Python can just capture the emulator's window render.
Alternatively, a connection can be made using SocketIO (Flask Socket IO and Javascript's client socket IO in my case) and they can communicate that way. Confirmed via the browser on the emulator and real device. Every emulator has ports to communicate to your native OS. I ultimately chose not to go this route as it's a little convoluted (2 servers, different languages, no better than ADB over LAN) but it's an option. Java (iirc) also runs SocketIO just fine and would likely be a decent option for many devs who are familiar with the language and wish to run some stuff natively on Android Devices.
Feeling physically ill atm and typing on a phone so my apologies for the present lack of examples and assistance. Hopefully I can catch the time to address this but, frankly, there are few use cases for this outside of the one I'm presently targeting and it's quite niche to begin with.

How to predict performance of a program for smartphones developed on a pc

I am developing a program that is going to be very performance-intense for Android/smartphones. Because I do this on a pc (Windows) I do not really know how my application will perform on a mobile device. I do not want to port this program to android until I have a good working version for Windows (this will be my first Android-app and I don't want to try to troubleshoot something when I'm not even sure whether my program is working).
I am searching for some database where I can compare pc-GPUs with mobile GPUs. I know that an accurate comparison is difficult between such different architectures, however, a small hint about the expected performance would be very helpful.
By the way, I am developing on a machine with an integrated Intel® HD Graphics 4400 and ideally, I want to compare it to something like an Adreno 306.
Rather than using benchmarks for the GPU, look at existing cross-platform applications with similar performance and see how it compares. Install it on your computer to make sure the intensiveness is similar (using whatever benchmarks you want), then install it on your android device to see if it can keep up to your expectations. You can find benchmarking apps or you can use the profilers on Android Studio to see how the device in question is handling the application.
This is about as good as you're going to get. Like you said, so much relies on the implementation and the vastly different architecture. Lastly, if you're building on a framework that builds to other platforms (libgdx, xamarin, etc), you should present a specific question to other users of that framework.

android minimum hardware specs for dev machine - can i code using a notebook?

So far I have been developing directly on my galaxy nexus and nexus 7 using the amazing AID app.
However, as the N7 can't provide logs due to it being jelly bean, i feel the need to get a mini notebook in order to utilise adb logcat.
My main worry is that something with only 1gb (2gb if i upgrade, which i will) and a 1.5-1.83GHz atom CPU won't be powerful enough.
I can possibly get around certain worries by not using emulators and testing directly on my two devices, so that will save me a great deal. Also I am tempted to just use vim and command line tools instead of eclipse which again might save me from a slow PC.
What do you guys think? Is the notebook way under powered? What if i just use vim and no emulators?
Side note, does anyone actually code in vim/command line?
something with only 1gb (2gb if i upgrade, which i will) and a 1.5-1.83GHz atom CPU
will work just fine, as long as you're not planning to run a tablet emulator. I sometimes have to work at my Asus EEEPC with the same exact CPU and I've got no problems so far
It is doable with 1gb RAM and using vim/commandline tools. However, eclipse provides a project wide perspective which is hard to duplicate in vim (vim power users may be as productive, if not more though). So in terms of memory 1, 2gb RAM will be fine. Testing on devices is always better than emulators.
One thing else though, a commandline build with multiple module dependency is non-trivial to setup and maintain. This is because Google has historically been modifying the build.xml file, breaking existing build scripts fairly regularly. So if you are well versed with build script internals and prepared to work on them you should be ok.
Debugging Android apps without Eclipse based breakpoint debugging support may be a significant issue too. Some bugs are caught in a lot lesser time with this. So plan accordingly if you don't want to use Eclipse.
Eclipse also provides very good JUnit/Robotium support for writing test cases, You won't get this with vim.
As I wrote down these points I think running Eclipse in 2gb notebook should be possible (just don't run other apps with doing development) and thus is recommended.
I have extensively used vim just not for Android development. You can also install vim plugin for eclipse if you prefer that.
Modern notebook hardware certainly is capable for software development; in fact, many (hobbyists as well as professionals) use a notebook as their main development platform.
However, with a mini / ultra-small form factor, you'll pay more for a less capable machine. Unless you need extreme mobility, I would suggest a standard notebook, with a little extra money spent on RAM (8+ GB) and an SSD. (Then, neither big IDEs nor emulation is out of scope.) If money is an issue, you can still get clunky-looking, but fairly powerful 15" or 17" laptops.
i think you Configuration is good enought to run Eclipse , Myself i had to Remove some Composant on my PC beacause we have 1 PC for Work/Internet/Eclipse and 1 PC for Gaming Etc ... , iam using Galaxy S2 and dont use Emulator many times , Yes i have some Slow Down some Time , but try Eclipse with the Minimal Configuration and No Emulators but Upgrade to 2 GB i have myself 2 GB Here and DUal Core E5200
Yeah that's under powered. For a windows PC I'd want 4gb of ram, not sure about Linux but atoms are dog slow either way.
I'm sure it'll work but it won't be fun, I'd be most worried about disk speed as that's what drives me nuts most.
I'd also take advantage of the ide and all its nice features too

Increase Android development speed

being a Java/Linux advocate, and having programmed my first Android app a while ago, nowadays I'm building a similar one this time in WPF (it's likely to be run in WP7). I have to admit that so far Eclipse/ADT seems to be no match to VisualStudio 9 in regards to development speed. The latter excels in the build/run speed cycle (it's obvious being Eclipse a java based app). Being my development HW an i3 laptop/4GB RAM/Win7 x64, my questions are:
Could I get a similar development speed I have today in VS9 in the "Android" environmnent if I had a state of the art processor (i7 ?)Would I have a performance boost if I worked in a Linux partition in my laptop?
Any additional hints are welcome.
Thanks
The primary reason ADT feels bulky and slow is because it is constantly rebuilding in the background. This proves useful when showing compile errors and warnings as you type, but when working on larger projects—especially when making changes to the manifest, XML files (including layouts, drawables and strings) and resources—the IDE will regularly lock up with a build progress bar, as some changes require a rebuild to complete.
You can disable automatic building via the Project menu. I use this regularly when making changes to layouts, but enable it again when writing code.
As for hardware: it appears that aapt runs only on one core, and from my experience, it runs noticeably faster on faster cores vs. more cores. (This is anecdotal, since the comparison here is a PC with two 2.11 GHz cores vs. a laptop with two 1.8 GHz cores.)
A colleague uses Linux for development; I'll inquire if he has noticed any speed increase since switching from Windows.

Categories

Resources