I am writing the following logic to read a text file line by line in python.
There are a lot of text files, one file is 10MB, one line is 300 bytes, about 20,000 lines.
The execution environment is running the command python.exe ./run.py on windows10 cmd.exe (not WSL)
When observing the time taken to process one file, there is a big difference of 2 to 40 seconds.
When I activate the cmd.exe window, it looks faster overall.
What is the reason for this difference?
Is there logic in windows that the active window process raises the priority?
The same phenomenon occurred with the combination of nodejs, electron, and windows10.
fileList = glob.glob("./logs/**/*.txt",recursive=True) fileList = sorted(fileList) for index,filePath in enumerate(fileList): allXmlList : List[str] =  with open(filePath, encoding="utf-8") as f: for line in f: line = line.lstrip("n").rstrip("n") thisLine = "" if thisLine.endswith("/>"): if thisLine not in allXmlList: allXmlList.append(thisLine) tempLine = "" elif thisLine.endswith("</xxx>"): if thisLine not in allXmlList: allXmlList.append(thisLine) tempLine = "" else: tempLine = thisLine + "n" anyProcess(allXmlList)
Source: Windows Questions