General methods for optimizing a program for speed

What are some common methods for optimizing a Java program in terms of speed. I use DOM Parser to parse an XML file, and then save certain words in an ArrayList, delete any duplicates, and then check these words, creating a Google search URL for each word, getting an html document, find the corrected word and save it with another ArrayList .

Any help would be appreciated! Thank.

+3
source share
4 answers

Why do you need to improve performance? From your explanation, it’s pretty obvious that the big bottleneck here (or performance) will be IO as a result of accessing the URL .

This, of course, will overshadow by an order of magnitude minor improvements in data structures or XML infrastructures.

A good general rule is that your big performance issues will be related to IO. Enough of humor, I'm at this very moment waiting for the database query to return in the batch process. He works for almost an hour. But I welcome any suggested improvements in my XML syntax library nonetheless!

Here are my general methods:

  • - (IO)? , , ( )?

  • (.. , , , - "" )? , Map, , .

  • - (, ), ?

  • (, jvisualvm, JDK) . JVM ?

+3

SAX , DOM. ArrayList , LinkedHashMap - , , ArrayList.

HTTP- Google, , . .

: . , , .

+3

, - , , . , 90% , .

, , . , ArrayList O (n²), , O (n), .

, , , , StackOverflow.

Edit

@oxbow_lakes, , , . , , , . " " , , . :

  • , . , . , , 99% Google.
  • . ():
    • XML
      • Ping Google .

"ping Google", , . :

  • XML
  • .
  • .

, , , , , . , TinyMCE javascript , -. , AJAX, , .

+1
source

These people are probably right, but a few random pauses will turn * possibly "into" definitely, and that's why. "

0
source

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


All Articles