Open colincharles opened 6 years ago
One performance boosting alternative I considered looking into was converting some of these functions to use Rcpp
. It is supposed to be very good in these loop counting scenarios.
Hello, and (many) apologies for missing these messages somehow!! These are great suggestions and I will work to incorporate them.
As we've been accumulating data since 2016, the xy2segvert function has been taking a bit longer with each addition of data from our telemetry experiment.
I was digging through the function and found that the
mapply
function was taking increasingly longer with more data. I was able to parallelize themapply
function toparLapply
using the parallel library. Thought someone might find this useful.For a general idea, right now we've got ~1.75M data points in our system (Red River - Manitoba, North Dakota, Minnesota) and on my machine the xy2segvert function takes about 6.5 minutes to run. By switching it to parallel and using 8 cores it's down to ~50 seconds and 2 cores was ~3.25 minutes
Here's the changes I added to the function.