yakra / DataProcessing

Data Processing Scripts and Programs for Travel Mapping Project
0 stars 0 forks source link

compute_stats_r branching micro-optimizations if bored #204

Closed yakra closed 2 years ago

yakra commented 2 years ago

Not user stats but stats in general. But anyway... https://github.com/yakra/DataProcessing/blob/7fb4d73e8bde139dbb5a46c970ea932429a63ec7/siteupdate/cplusplus/classes/Route/compute_stats_r.cpp#L37-L40

With just some {}s & indentation, we can fold the if (system->active()) check into the if (system->active_or_preview()) block and save extraneous checks. If not active_or_preview(), we know it's not active().

Better yet? Replacing the whole thing with a switch makes things readable enough that we can lose the comments. Much cleaner. There should be fewer conditionals under the hood:

Yet this appears to be running slower. Why? Is it just noise in the data? Become bored & test with a bigger data set.

Hidden systems? Once accounting for hidden systems, we're winning a little more with brevity & readability. Don't need to add if (system->level == 'h') continue; or anything, just change default to case 'd'. Might even end up being faster too; we avoid an extra test for a/p systems.

Earlier code: https://github.com/yakra/DataProcessing/blob/7fb4d73e8bde139dbb5a46c970ea932429a63ec7/siteupdate/cplusplus/classes/Route/compute_stats_r.cpp#L13-L22 Some or all of these ideas may or may not be good ones, or make it to production

yakra commented 2 years ago

prelim rankings before bumping up the reps n'at

BT 1st pass .1633 .1611 .1636

box -t 4 -t 1 comments
BT1pass 102 !
BT2pass 120 210
lab1 021 021
lab2 021 021
lab3 201 012
lab4 012 102 (redo 2, due to SCPing files partway thru?)
lab5 0(tie) 120
bsdlab 210 210