From: Aaron Taylor Date: Sat, 15 May 2021 22:15:08 +0000 (-0700) Subject: Modified permuteExistingNumbers() to pre-allocate sufficiently large slice for all... X-Git-Url: http://git.subgeniuskitty.com/surreal-numbers/.git/commitdiff_plain/8be725f2ca1fc13ac01f8f3a553e6a8803d08d91?hp=8be725f2ca1fc13ac01f8f3a553e6a8803d08d91 Modified permuteExistingNumbers() to pre-allocate sufficiently large slice for all results. Based on profiling, significant time was spent in growSlice() and memMove() as a result of the per-number slice append(). Consolidating the allocations resulted in significant speed and memory usage improvements. Benchmarking command: time ./ch1-breeding-numbers -generations 13 -silent go tool pprof ch1-breeding-numbers 13gen-memprofile-gen12.mprof top25 Before: 71.978u 3.726s 0:31.79 238.0% 0+0k 40+75io 353pf+0w Showing nodes accounting for 3.70GB, 100% of 3.70GB total After: 38.303u 2.233s 0:23.41 173.1% 0+0k 40+62io 354pf+0w Showing nodes accounting for 2.29GB, 100% of 2.29GB total ---