Java API Runtime

Is there a good resource for getting runtime for standard API functions? This is somewhat confusing when trying to optimize your program. I know that Java is not particularly fast, but I cannot find much information about it at all.

Example: If I search for a specific token in a file, it’s faster to scan each line using string.contains (...) or to add about 100 lines, placing them in the local line that they execute contains on this fragment.

+3
source share
6 answers

AFAIK, there are no standard benchmarks for API methods, and in fact there may be various JVM-based implementations that you use. Couple that with JVM JIT optimizations, garbage collection and many other things, and I doubt you can get globally significant numbers. Most of what you can do is write your own tests.

Some methods determine the computational complexity of operations in their JavaDocs. Some other methods describe other performance issues. Make sure you know about them and listen to them.

But besides this, most likely you are doing premature optimizations. Use the profiler to see that this is actually a bottleneck.

, , .. , , . , - , .

+5
+3

, , . , profiler. NetBeans .

, , , . , , , , .

+1

, , - . , , -, . Java, .

+1

Profiler - log4j ( Apache Commons Logging ..), , : , , .

- , , , CSV .., .

+1
source

if we skip the input time of the IO disk and just look at the processor time spent on your code, the second option will be much slower than the first.

+1
source

Source: https://habr.com/ru/post/1750587/


All Articles