Any way to further optimize Java reflective method invocation?

前端 未结 5 1363
感动是毒
感动是毒 2020-12-08 08:22

I am wondering if there are any additional optimizations I can implement to improve the speed of reflective invocations in Java. Not that the performance is prohibitive, but

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-08 08:54

    If the cost of invocation is less than 10% of the cost of what goes on in the method, it's hardly worth worrying about.

    You can determine that by running it 10^6 times in a loop, with and without the guts of the routine. Time it with a stopwatch, so seconds translate to microseconds.

提交回复
热议问题