![]() |
Re: Google Sheets OPR Calculator
Quote:
Quote:
printing T (creating full team list, sorting it, getting unique values, printing) is too fast to time manually printing b and A: ~21sec to create/print both printing formula: fast One weird thing I noted is that the first 188 rows of A (first 94 matches) are printed very quickly, then there's a long pause (at least 15sec the last time I ran it) before the remaining lines are printed. I'm not sure what's behind this, but I'll look into it more. Code:
function calculateOPR2() {Quote:
|
Re: Google Sheets OPR Calculator
Quote:
I think you missed the boat here. Your code has three passes through the matches, and the final pass has an inner loop which loops through the teams. The pseudo-code I posted does a single pass through the 8col match data, with no inner loops in that single pass. That single pass accomplishes everything you need. Give it a try! |
Re: Google Sheets OPR Calculator
Quote:
I also figured out what's taking so much time: it's the repeated .getRange().setValue(). There's another function, setValues() that allows me to print the entire array at once that really speeds it up. However, the array must be a consistent size, so I had to keep the loop to create T so I could initialize A. It also seems like fill() doesn't work in scripts, so I had to loop through T to set A to zero, otherwise when I printed out A it'd be filled with "NOT_FOUND". I did cut out the loop for b (not sure why I had it there in the first place). Although I did manage to implement your pseudo-code, the only method I found to make that work would be to print A directly (instead of creating the array first), which took longer than looping. It also results in the OPRs not being sorted, which is a convenience I'd sacrifice a bit of time for. Hopefully that now addresses your point? I'll post my updated code once I clean it up a bit. |
Re: Google Sheets OPR Calculator
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
|
Re: Google Sheets OPR Calculator
Quote:
Array values are set to null (I think--if I set a cell value to that, it comes out as either "undefined" or "NOT_FOUND" depending on whether I set an individual cell or range) Quote:
Quote:
Quote:
Quote:
Quote:
This has been an interesting conversation though, so thank you for that. I will be updating the posted spreadsheet with the new script soon (currently cleaning it up a bit, but it should be up by tonight) for anyone who wants it. |
| All times are GMT -5. The time now is 10:41. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi