Java performance tips

前端 未结 14 1752
傲寒
傲寒 2021-02-01 20:04

I have a program I ported from C to Java. Both apps use quicksort to order some partitioned data (genomic coordinates).

The Java version runs fast, but I\'d like to get

14条回答
  •  耶瑟儿~
    2021-02-01 20:45

    do not try to outsmart the jvm.

    in particular:

    • don't try to avoid object creation for the sake of performance

    • use immutable objects where applicable.

    • use the scope of your objects correctly, so that the GC can do its job.

    • use primitives where you mean primitives (e.g. non-nullable int compared to nullable Integer)

    • use the built-in algorithms and data structures

    • when handing concurrency use java.util.concurrent package.

    • correctness over performance. first get it right, then measure, then measure with a profiler then optimize.

提交回复
热议问题