A way to estimate or predict the processing time of a Jsoup HTML fragment?

Some of the webpages I process in Jsoup are heavy. By โ€œheavyโ€, I mean that the page contains a lot of HTML (suppose that the page is already loaded), or it requires several iterations in one document (it is created only once through Jsoup.parse () ).

For this reason, I would like to present a progress bar to the user with an expectation of how much time is left.

One approach is to simply measure the amount of HTML (in KB or MB) and come up with a speed factor (unfortunately, it completely depends on the speed of the system in which this code works).

Another approach is to count the number of nodes ?

Due to the obvious deterministic nature of this, am I causing problems?

Ideas for the best ways to handle this?

+6
source share
2 answers

Summing up the answers so far: No one can estimate or predict Jsoup processing time for an HTML fragment.

The reason is that Jsoup.parse() is a time-consuming component, Jsoup can run on multiple platforms / devices, some of them very slow, some are very fast, and there is no way (to wait) for Jsoup to correlate its stages / operations processing with the architecture on which it runs.

+1
source

What will I tell you:

 long start = System.currentTimeInMilis(); //Processing long end = System.currentTimeInMilis(); long timeToProcess = end - start; 

But I really think that this is useless, because you depend on the page server, Internet speed, processing power. There are too many to predict. Also ... the Jsoup API of the EXTREMELY selector is fast. Also .. The time it takes to connect is a longer wait. Which you really cannot predict. Hope this helps

0
source

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


All Articles