Why huge performance gap between opencv c++ native and java code on Android?
Hi guys, just wonder if anybody have hit similar case?
The strange thing is: the android java code, e.g., GaussianBlur() is stably 4~5x fast, comparing to calling the same function in c++ native code on android.
For a 1920x1080 image, java needs around 40~50ms in HTC820mu (snapdragon 615, https://www.qualcomm.com/products/sna...) & HTC one M9 (snapdragon 810, https://www.qualcomm.com/products/sna... ). The native c++ code needs 200+ ms.
For the same image, iMac with 3GHz i5 processor and opencv with SSE enabled, running the same op (c++ code) costs around ~15 ms.
I thought the android java performance number is reasonable (1/2 ~ 1/3 of that of iMac) considering the float point performance gap between low-freq ARM and high-freq x86-64. However I dont understand why the native c++ API calling is so slow since the java API is implemented with native c/c++ method (GaussianBlur_0(...) - which I failed to locate it in opencv source ).
BTW: I have tried both the OpenCV4Android 3.4.1 and the same version built by myself. Both of them have NEON enabled, VFP3 disabled and use softfp-abi.
Any ideas? Thanks much!
the code snippet as following: 1. java code
native code:
your java code measures "wall time", while the c++ code uses something based on cpu clock, so you compare apples to pears.
use cv::getTickCount() in both java/c++ code, and report back, please.
Thanks. I will try it.