androidの実装で「インタフェースを使うと2倍遅くなる」は間違い

インタフェースの代わりに実装クラスを書いた場合の差は6%〜無し

"android パフォーマンス"等で検索すると、以下のサイトが上位に出てきます。
Android開発でのパフォーマンス設計のBest Practice - dann's blog - #
http://labs.techfirm.co.jp/android/cho/1283
どちらもandroidの公式ドキュメント
Performance tips  |  Android Developers
のパフォーマンスに関する部分を元にしているのですが、この中で現在は訂正(に近い扱い)をされている内容があります。この内容は個人的に特にギョッとしていた部分なので、訂正内容を書いておきます。
なお、当初のドキュメントでは確かにお二方のブログのように書いてあったので、お二方が間違っていたのではなく、ドキュメントが良くなかったという事です*1

間違ったパフォーマンスTips

インターフェースは使わない

Map myMap1 = new HashMap();  
HashMap myMap2 = new HashMap();  

オブジェクト指向になぞらえば、上記のようなケースでは多様性の恩恵を受けるために、Mapインターフェースを使った実装が好まれるが、Androidの実装ではパフォーマンス的にNG。インターフェースを使う場合、使わない時と比べて2倍近く遅くなることがあります。

http://labs.techfirm.co.jp/android/cho/1283Android Techfirm Labさんのブログより引用
訂正内容

On devices without a JIT, it is true that invoking methods via a variable with an exact type rather than an interface is slightly more efficient. (So, for example, it was cheaper to invoke methods on a HashMap map than a Map map, even though in both cases the map was a HashMap.) It was not the case that this was 2x slower; the actual difference was more like 6% slower. Furthermore, the JIT makes the two effectively indistinguishable.

公式ドキュメントより引用

適当に訳すと、

  • JIT無しの場合、インタフェース(Map)ではなく実装クラス(HashMap)を書いた方が少しは速い。
  • 但しその差は、2倍ではなく6%くらい
  • JIT有りの場合(2.2以降ですね)、差は無い

との事です。

インタフェースではなく実装クラスを書くのは相当違和感があったし、androidから入ったJavaプログラマに変な癖がつくと良くないのでホッとしました。

ついでに、フィールドをローカル変数にキャッシュする件

こちらは、

  • JIT無しの場合、キャッシュした方が20%速い
  • JIT有りの場合、差はない

そうです。こちらも今後はやめた方が良いルールのようですね。

On devices without a JIT, caching field accesses is about 20% faster than repeatedly accesssing the field. With a JIT, field access costs about the same as local access,

*1:ドキュメントにも、"Previous versions of this document made various misleading claims. We address some of them here."とあります