diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-03-07 23:46:19 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-07 23:46:19 +0000 |
| commit | 259ff4114d0d3e9599fa103ec0f81b502dbbf2a9 (patch) | |
| tree | 6fb11a78217a9df8cdf4069f5f1b35200a7ca1f2 /challenge-102/duncan-c-white/OptimizingTask1 | |
| parent | 0bc69ba8f00534a5e7bcfadf2926518c004e74aa (diff) | |
| parent | fc922ab6b83e4082c1bf04132e91c685a22eb0d9 (diff) | |
| download | perlweeklychallenge-club-259ff4114d0d3e9599fa103ec0f81b502dbbf2a9.tar.gz perlweeklychallenge-club-259ff4114d0d3e9599fa103ec0f81b502dbbf2a9.tar.bz2 perlweeklychallenge-club-259ff4114d0d3e9599fa103ec0f81b502dbbf2a9.zip | |
Merge pull request #3684 from dcw803/master
imported my solution's to this week's tasks
Diffstat (limited to 'challenge-102/duncan-c-white/OptimizingTask1')
| -rw-r--r-- | challenge-102/duncan-c-white/OptimizingTask1 | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/challenge-102/duncan-c-white/OptimizingTask1 b/challenge-102/duncan-c-white/OptimizingTask1 new file mode 100644 index 0000000000..f108fc1873 --- /dev/null +++ b/challenge-102/duncan-c-white/OptimizingTask1 @@ -0,0 +1,50 @@ +tried some optimizations of task 1 (rare numbers). All times are for n==8 or 9 +I used Devel::NYTProf to profile each version, then made small optimizations, +then reprofiled. See "run.sh" for how to run a particular version through +the profiler, generate the report, and copy it into a web-accessible directory +for viewing: + +ch-1.pl: the original, not optimized + time(8): 0:34.31 + time(9): 5:56:10 + +ch-1a.pl: observation from rare numbers webpage ("Properties of.." + section): rare numbers start with even top digit + time(8): 0:24.46 + time(9): 4:10.61 + +ch-1b.pl: only consider rare numbers starting with even top digit.. + time(8): 0:15.35 + time(9): 2:44.34 + +ch-1c.pl: lots of optimizations, especially 3 separate rare block + functions: rareblock(), rareblock05() and rareblock2378(). + time(8): 0:06.35 + time(9): 1:06.64 + +ch-1d.pl: lots more optimizations, especially: rather than generate x and + test x%10 == d, generate y (1/10th the range) and make + x = 10y + d: 1/10th the work, but same x's as before + time(8): 0:03.92 + time(9): 0:40.21 + +ch-1e.pl: inlined israre() into the slowest rareblock2378() func + time(8): 0:03.39 + time(9): 0:34.49 + +ch-1f.pl: inlined israre() into the next slowest rareblock05() func + time(8): 0:03.12 + time(9): 0:31.47 + +ch-1g.pl: inlined israre() into the last rareblock() func + time(8): 0:02.94 + time(9): 0:28.79 + +ch-1h.pl: inlined perfectsquare() everywhere + time(8): 0:02.15 + time(9): 0:21.20 + +ch-1i.pl: reintroduced israre() but with two inlined calls to perfectsquare() + sweet spot: clear, shows problem structure nicely, plus pretty fast + time(8): 0:03.23 + time(9): 0:32.34 |
