Use multiprocessing to speed up processing of input files #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Use
multiprocessing
to speed up processing of input files, using the number of processes which matches the CPU count.On my old dual-core Mac, the processing step speeds up:
Will be a larger gain for machines with more CPUs.
multiprocessing
needs a single worker function, this is the newprocess_file
which decides which ofprocess_gpx
andprocess_fit
to call. They also need to be top-level functions to work withmultiprocessing
.I also formatted the file using the popular Black autoformatter:
python -m pip install -U black black .
I also fixed a bug when using an input path like
~/dir
, it needs to expand~
before checking it's a dir (and appending*
).