JNI Performance

后端 未结 3 1983
暗喜
暗喜 2021-02-11 07:05

Our main program is in java but the code that extracts our data from storage is written in C. I need to build an HDF5 file from extracted data. Would it be better to use JNI to

3条回答
  •  孤城傲影
    2021-02-11 07:25

    The function call boundary is "slow", so if you're doing many calls to your native routine, then performance will suffer.

    An example of the kind of thing that may benefit from moving to JNI (I emphasize may, because Java is more than fast enough for many purposes) would be a routine to do some sort of image processing on a large bitmap. But to call a JNI routine for each pixel would be much, much slower than doing it within a loop in pure Java.

    Extracting data from one format to another is, frankly, the kind of thing best done in a "scripting" language like Python, and will never be bound by CPU. Rather, the disk speed is going to be way, way slower than any language interpreter.

提交回复
热议问题