alberto mancini - a few benchmark on android
DESCRIPTION
Alberto Mancini - A few benchmark on Android 15 Aprile 2014 - ANdroid conference Ancona - GDG AnconaTRANSCRIPT
![Page 1: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/1.jpg)
ANdroidA few Benchmarks
Alberto Mancini - Francesca Tosi 15 Aprile 2014
![Page 2: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/2.jpg)
![Page 3: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/3.jpg)
HTM
L5 D
ev
http://github.com/jooink
http://www.jooink.com
http://jooink.blogspot.com
![Page 4: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/4.jpg)
It ju
st w
asn'
t rea
dy
Si riferiva a FB su mobile che era web based e stava facendo la prima intervista “After the company’s continuous stock price drop” (ndr)
http://mashable.com/2012/09/11/mark-zuckerberg-post-ipo-interview/
![Page 5: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/5.jpg)
fast
book
http://www.sencha.com/blog/the-making-of-fastbook-an-html5-love-story
fastbook, Sencha’s fb demo client
"... is really promising, but it is running in the “browser”. When you make an “installable” app, you can only use WebView, which is a second-class and slower browser."
It's a technology demo that shows what developers can do with HTML5 if they take the right approach, and use the right frameworks and tools
![Page 6: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/6.jpg)
(*)W
ebA
pps ● cached
● offline capable ● mobile-webapp-capable● Homescreen-installed● hosted app● packaged app
https://developers.google.com/chrome/apps/
https://developer.mozilla.org/en-US/Apps/Build/installable_apps
secondo alcuni sono una liberazione dai marketplace (i.e. Google Play & AppStore)
secondo alcuni tra l’altro alcune tecnologie vengono ritardate dai produttori per non perdere il potere che viene dai marketplace
![Page 7: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/7.jpg)
GW
T/M
GW
T Java to Javascript compilerEmulated JREWidgets
Deferred BindingMultiple BrowsersCompiled Resources...
![Page 8: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/8.jpg)
xché
una codebase e tante 'incarnazioni' dell'applicazione.
![Page 9: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/9.jpg)
Mar
ker B
ased
AR
http://code.google.com/p/gwt-webgl/http://code.google.com/p/gwt-nyartoolkit/
http://picshare.jooink.com
c.a. 25 fps
![Page 10: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/10.jpg)
GW
T-B
oofc
vGWT-Boofcv sample at:http://goo.gl/3IJQgs
![Page 11: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/11.jpg)
GW
T-B
oofc
vGWT-Boofcv sample at:http://goo.gl/3IJQgs
![Page 12: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/12.jpg)
stra
tegy
● native ?● hybrid ?● browser-based ?
![Page 13: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/13.jpg)
Nat
ive,
ND
K capire quanto possiamo guadagnare in termini di performance basandoci su differenti tecnologie
Applicazione Android NDKche usa librerie native
Applicazione Android Javaper Dalvik
![Page 14: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/14.jpg)
Ben
chm
arks
il medesimo algoritmo implementato con tecnologie diverse eseguito sul medesimo dispositivo
![Page 15: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/15.jpg)
Ben
chm
ark In entrambe le applicazioni precedenti una
operazione semplice ma computazionalmente costosa è fare la conversione in grayscale delle immagini
![Page 16: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/16.jpg)
Rul
es RGB jbyte[1024*1024*3]
Average on 1000 runs
grayjbyte[1024*1024]
1
0.299*R+0.587*G+0.114*B → Y2
3
![Page 17: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/17.jpg)
Test
dev
ice Galaxy Tab3
Intel Atom CPU Z25602 core - 1.60 GHz Android 4.4.2Architettura i686
![Page 18: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/18.jpg)
Com
petit
ors Benchmarks on:
Java <byte> NDK <jbyte>IPP <Ipp8u>
![Page 19: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/19.jpg)
Com
petit
ors Benchmarks on:
Java <byte> NDK <jbyte>IPP <Ipp8u>
Intel Integrated Performance Primitives
![Page 20: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/20.jpg)
Com
petit
ors Benchmarks on:
Java <byte> NDK <jbyte>IPP <Ipp8u>Chrome <Uint8Array>Firefox <Uint8Array>Aurora <Uint8Array>
![Page 21: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/21.jpg)
Cod
ice
(Jav
a) Java:void compute(byte[] in, byte[] out) { for(int i=0, j=0; i< out.length; i++, j+=3) out[i] =
(byte)(0.299 * in[j] + 0.587 * in[j+1] + 0.114 * in[j+2]); }
Using FP arithmetics !!
We cannot (at least without asm.js) coherce numbers to integers in js so we chosen not to optimize here.
![Page 22: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/22.jpg)
Det
ails
(ND
K) https://developer.android.com/tools/sdk/ndk/index.html
La documentazione non e’ il punto di forza dell’NDK
https://github.com/jooink/ndk-cpuid
● start the (intel) avd ● enter in the jni folder & execute 'ndk-build'● from the CPUIDApp root dir execute 'ant debug'● adb install -r bin/CPUIdApp-debug.apk
![Page 23: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/23.jpg)
Cod
ice
(C, j
ni) void JNICALL … jbyteArray in, jbyteArray out) {
jsize len_out = (*env)->GetArrayLength(env, out); ... jbyte *body_out = (*env)->GetByteArrayElements(env, out, 0); for(i=0, j=0; i< len_out; i++, j+=3) body_out[i] = (jbyte)(0.299 * body_in[j] + … );
(*env)->ReleaseByteArrayElements(env, in, body_in, 0); ... }
![Page 24: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/24.jpg)
Det
ails
(IPP
) Bundled in BeaconMountain beh … la ‘preview’
http://software.intel.com/en-us/intel-ipp
… ed avete la IPP per android x86 !!!
Scaricate la versione per linux ( la evaluation, or 199$ :( )
Installatela ( vi serve una macchina linux )
Copiate le librerie (*.a) e gli include (*.h) (32bit statici non-threaded)
![Page 25: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/25.jpg)
Cod
ice
(IPP)
… jni ...
IppiSize srcRoi = { 1024, 1024 }; Ipp8u* pSrc = body_in; Ipp8u* pDst = body_out; ippiRGBToGray_8u_C3C1R(pSrc ,1024, pDst, 1024, srcRoi);
… jni ...
![Page 26: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/26.jpg)
Res
ults
nat
ive
![Page 27: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/27.jpg)
Res
ults
nat
ive
minmaxavg
![Page 28: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/28.jpg)
Cod
ice
(js) var len_out = outb.length;
var i,j;for(i=0, j=0; i< len_out; i++, j+=3)
outb[i] = (0.299 * inb[j] + 0.587 * inb[j+1] + 0.114 *inb[j+2]);
var buffer_in = new ArrayBuffer(size*3);var buffer_out = new ArrayBuffer(size);
var inb = new Uint8Array(buffer_in);var out = new Uint8Array(buffer_out);
![Page 29: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/29.jpg)
Res
ults
jsminmaxavg
![Page 30: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/30.jpg)
Gra
zie Francesca Tosi
Alberto Mancini [email protected]
Github: github.com/jooink/
www.jooink.comjooink.blogspot.com
![Page 31: Alberto Mancini - A few benchmark on Android](https://reader033.vdocuments.us/reader033/viewer/2022052900/555e2684d8b42a384f8b4f4e/html5/thumbnails/31.jpg)
Det
ails
(HA
XM) Bundled in BeaconMountain
http://software.intel.com/en-us/android/articles/intel-hardware-accelerated-execution-manager
cambia la vita con le immagini x86
Attenzione pianta OSX, maverickinstallare lo hotfix