型変換テンプレートで変換する際、中間オブジェクトを生成しないようにした
Android上でJSONとMessagePackの簡単なベンチマークをとってみた - komamitsu.log の続き。
http://syuki.skr.jp/files/201204041/furuhashi-master-last-iso-pdfa.pdf を読んだところ、Unpacker.read(Class
use unpacker.read(Class<T>) · ea24660 · komamitsu/AndroidMsgpackBenchmark · GitHub
Android2.2 | Android4.2 | ||
Array S | JSON | 6421 | 2818 |
Msgpack | 14636 | 1121 | |
Array D | JSON | 1423 | 597 |
Msgpack | 16284 | 6300 | |
Msgpack: Unpacker.read(Class |
7458 | 4167 | |
Map S | JSON | 3282 | 1894 |
Msgpack | 19394 | 1117 | |
Map D | JSON | 1044 | 614 |
Msgpack | 17350 | 7754 | |
Msgpack: Unpacker.read(Class |
8676 | 5223 |
結果は、デシリアライズの速度が前回のJSON:Msgpack=10~17:1という結果から, JSON:Msgpack=8:1と改善。
Android上でJSONとMessagePackの簡単なベンチマークをとってみた
ベンチの概要としては、100byte x 50000の配列、100byte(value) x 30000の辞書をJSON, MessagePackでシリアライズ・デシリアライズしてどんなもんか見てみようかと。
- Android2.2(IS06)の場合
I/MsgpackExampleActivity ( 8963): benchmarkJsonArray: serialize start I/MsgpackExampleActivity ( 8963): benchmarkJsonArray: serialize end :6421 I/MsgpackExampleActivity ( 8963): benchmarkJsonArray: deserialize start D/MsgpackExampleActivity ( 8963): benchmarkJsonArray: size=50000 I/MsgpackExampleActivity ( 8963): benchmarkJsonArray: deserialize end :1423 I/MsgpackExampleActivity ( 8963): benchmarkJsonMap: serialize start I/MsgpackExampleActivity ( 8963): benchmarkJsonMap: serialize end :3282 I/MsgpackExampleActivity ( 8963): benchmarkJsonMap: deserialize start D/MsgpackExampleActivity ( 8963): benchmarkJsonMap: size=30000 I/MsgpackExampleActivity ( 8963): benchmarkJsonMap: deserialize end :1044 I/MsgpackExampleActivity ( 8963): benchmarkMsgpackDynamicArray: serialize start I/MsgpackExampleActivity ( 8963): benchmarkMsgpackDynamicArray: serialize end :14636 I/MsgpackExampleActivity ( 8963): benchmarkMsgpackDynamicArray: deserialize start I/MsgpackExampleActivity ( 8963): benchmarkMsgpackDynamicArray: deserialize end :16284 I/MsgpackExampleActivity ( 8963): benchmarkMsgpackDynamicMap: serialize start I/MsgpackExampleActivity ( 8963): benchmarkMsgpackDynamicMap: serialize end :19394 I/MsgpackExampleActivity ( 8963): benchmarkMsgpackDynamicMap: deserialize start I/MsgpackExampleActivity ( 8963): benchmarkMsgpackDynamicMap: deserialize end :17350
- Android 4.2 (Nexus7)
I/MsgpackExampleActivity (20424): benchmarkJsonArray: serialize start I/MsgpackExampleActivity (20424): benchmarkJsonArray: serialize end :2818 I/MsgpackExampleActivity (20424): benchmarkJsonArray: deserialize start D/MsgpackExampleActivity (20424): benchmarkJsonArray: size=50000 I/MsgpackExampleActivity (20424): benchmarkJsonArray: deserialize end :597 I/MsgpackExampleActivity (20424): benchmarkJsonMap: serialize start I/MsgpackExampleActivity (20424): benchmarkJsonMap: serialize end :1897 I/MsgpackExampleActivity (20424): benchmarkJsonMap: deserialize start D/MsgpackExampleActivity (20424): benchmarkJsonMap: size=30000 I/MsgpackExampleActivity (20424): benchmarkJsonMap: deserialize end :614 I/MsgpackExampleActivity (20424): benchmarkMsgpackDynamicArray: serialize start I/MsgpackExampleActivity (20424): benchmarkMsgpackDynamicArray: serialize end :1121 I/MsgpackExampleActivity (20424): benchmarkMsgpackDynamicArray: deserialize start I/MsgpackExampleActivity (20424): benchmarkMsgpackDynamicArray: deserialize end :6300 I/MsgpackExampleActivity (20424): benchmarkMsgpackDynamicMap: serialize start I/MsgpackExampleActivity (20424): benchmarkMsgpackDynamicMap: serialize end :1117 I/MsgpackExampleActivity (20424): benchmarkMsgpackDynamicMap: deserialize start I/MsgpackExampleActivity (20424): benchmarkMsgpackDynamicMap: deserialize end :7754
眠いので結果に関しては整形して見やすくしたりしない方向で....
自分でも見づらかったので整形 (単位はmsec)。
Android2.2 | Android4.2 | ||
Array S | JSON | 6421 | 2818 |
Msgpack | 14636 | 1121 | |
Array D | JSON | 1423 | 597 |
Msgpack | 16284 | 6300 | |
Map S | JSON | 3282 | 1894 |
Msgpack | 19394 | 1117 | |
Map D | JSON | 1044 | 614 |
Msgpack | 17350 | 7754 |
あと、三回程度繰り替えしても大体同じ結果。
結果の概要:
- Android2.2かつ低スペックのIS06ではJSONの方が総じて速かった。シリアライズが2.5〜6倍程度、デシリアライズが10〜16倍程度。
- Android4.2で高スペックのNexus7ではシリアライズに関してはmsgpackのほうが2倍程度速く、デシリアライズに関してはJSONのほうが10倍程度速かった。
- MessagePack on Androidはデシリアライズが結構遅め?
まだあんまりMessagePackの仕様について把握して無いので、もうちょっと原理を抑えてから再度試みてみたい(そして眠りたい)。あと、別の要因がからんでいるかも、とか。
Boyer–Moore string search algorithm
実装したことが無かったなぁ、とふと思ったので、ちょっと書いてみた
merge sort
あまりに最近Cを書いてないので適当にマージソートでも書いてみたら、やはりスラスラかけなかった件について。
NewstreamをWebViewからListViewに変更
まとめ系ニュースを、さらにまとめて眺める系アプリ作った - komamitsu.log で作ったときはサーバー側でHTML作って、Android側ではWebViewで表示させていたのですが、どうにももっさりしていたので、えいやとListViewに書き換えました。
手元の古のIS06ではかなり画面の表示が高速化されたので嬉しい。
読んでおきたい記事メモ
http://android-developers.blogspot.jp/2011/06/new-editing-features-in-eclipse-plug-in.html
http://android-developers.blogspot.jp/2011/05/introducing-viewpropertyanimator.html
http://android-developers.blogspot.jp/2011/03/identifying-app-installations.html
http://android-developers.blogspot.jp/2011/02/android-30-fragments-api.html
http://android-developers.blogspot.jp/2011/03/renderscript.html
http://android-developers.blogspot.jp/2011/07/custom-class-loading-in-dalvik.html
http://android-developers.blogspot.jp/2011/07/debugging-android-jni-with-checkjni.html
http://android-developers.blogspot.jp/2011/06/things-that-cannot-change.html
http://android-developers.blogspot.jp/2011/01/processing-ordered-broadcasts.html
http://android-developers.blogspot.jp/2010/12/its-not-rooting-its-openness.html
http://android-developers.blogspot.jp/2010/12/analytics-for-android-apps.html
http://android-developers.blogspot.jp/2010/12/new-gingerbread-api-strictmode.html
http://android-developers.blogspot.jp/2010/12/saving-data-safely.html
http://android-developers.blogspot.jp/2010/10/improving-app-quality.html
http://android-developers.blogspot.jp/2010/10/traceview-war-story.html
http://android-developers.blogspot.jp/2010/09/proguard-android-and-licensing-server.html
http://android-developers.blogspot.jp/2010/07/multithreading-for-performance.html
http://android-developers.blogspot.jp/2010/07/apps-on-sd-card-details.html
http://android-developers.blogspot.jp/2010/06/game-development-for-android-quick.html
http://android-developers.blogspot.jp/2010/05/dalvik-jit.html
http://android-developers.blogspot.jp/2010/05/be-careful-with-content-providers.html
http://android-developers.blogspot.jp/2010/04/multitasking-android-way.html
http://android-developers.blogspot.jp/2009/11/optimize-your-layouts.html
http://android-developers.blogspot.jp/2009/11/integrating-application-with-intents.html
http://android-developers.blogspot.jp/2009/05/drawable-mutations.html
http://android-developers.blogspot.jp/2009/02/android-layout-tricks-1.html
http://android-developers.blogspot.jp/2009/02/android-layout-tricks-2-reusing-layouts.html
http://android-developers.blogspot.jp/2009/03/android-layout-tricks-3-optimize-by.html
http://android-developers.blogspot.jp/2009/02/faster-screen-orientation-change.html
http://android-developers.blogspot.jp/2009/01/why-is-my-list-black-android.html