LoginSignup
7
5

More than 5 years have passed since last update.

ZenjectのPerformance

Last updated at Posted at 2018-12-02

こんにちは、DI好きですか?
僕は大好きです
でも手動で依存関係を注入するのはつらいです…
そこでZenjectに自動的に注入してもらいましょう
Zenject入門はこちら

でもゲームプログラマーならパフォーマンスが気になりますよね
win standaloneでprofiler測定してみました!(↓はいずれもprofilerの値

ソースコードはこちら

処理時間 [ms]

配列数 normal inject*1 inject*10
1000 1.44 15.68 52.31
10000 8.27 58.15 160.36

GC Alloc [KB]

配列数 normal inject*1 inject*10
1000 23.5 242.5 378.8
10000 234.4 2252.8 3072

まとめ

zenjectを使ってpureC#クラスを作成すると大雑把に10倍以上の時間がかかりますね
inject数が増えれば時間も増える傾向にありますね

GC allocも10倍くらい消費します

ターゲットデバイスに依りますが
要素数が1000を超えると処理落ちするし、GC allocも大幅に増えるのでzenjectを使うより手動DIした方がよさそうです

7
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
5