threads don't work in parallel
Posted: 13 Jun 2021, 15:05
My script needs a relatively long time to initialize all data. It has to load a 5MB file over the internet, analize this file, load a local text file, build a (big) array of object from this text file and sort this array. All this takes some time. I wanted to increase the speed by placing the main two tasks which are completely independent from each other in timed subroutines, so that they run in parallel:
The debug output looks like this:
So this shows that initqueues() is only started when DownloadHtmlfile is finished, no parallel processing of the two threads. It's also funny that htmldownload starts first, though it's timed to start after 5 ms while Initqueues is timed to start after 3ms.
How can I have the two threads execute in parallel?
And any other hints how to speed processing? There a lot to do, still the same job would not need more than a a few seconds in a compiled language like Delphi. I have already placed listlines, off before the main loops and placed most commands of those loops in a "single code line" using continuation lines
Code: Select all
settimer, InitQueues, -3
settimer, DownloadHtmlFile, -5
...
InitQueues() {
debug("InitQueues " xtime())
....
}
DownloadHtmlfile() {
t:=substr(xtime(),12)
...
t1:=substr(xtime(),12)
...
debug(format("DownloadHtmlfile {}-{}-{}, {} files",t,t1,substr(xtime(),12),NL.Count()))
}
The debug output looks like this:
Code: Select all
804 DownloadHtmlfile 19:41:10-19:41:14-19:41:32, 12885 files <---- 19:41:32 is the ending time of this routine
209 InitQueues 19:41:32
How can I have the two threads execute in parallel?
And any other hints how to speed processing? There a lot to do, still the same job would not need more than a a few seconds in a compiled language like Delphi. I have already placed listlines, off before the main loops and placed most commands of those loops in a "single code line" using continuation lines