mooreslaw.frink

Download or view mooreslaw.frink in plain text format


/* Calculate Moore's law and the benefit of waiting to start a long-running
   calculation because you assume computers are going to get faster.

   If you have a "doubling time" d (the value that has been found empirically
   is that the speed of computing devices has roughly doubled every 18
   months), you can put off starting the problem until the projected time to
   solve it is less than:

   d/ln[2]

   For a doubling time d of 18 months, this works out to about 26 months.  If
   a problem's going to take longer to solve than that, and you've got your
   algorithm optimized, you might as well just sit back and have a beer.
*/


// Doubling time
d = 18 months

t[r, d] := (d/ln[2]) ln[r ln[2]/d]

r = eval[input["Enter time to solve problem (e.g. \"5 years\"): "]]

t = t[r,d]
factor = 2^(t/d)
tt = r/factor

println["Time to complete: " + format[r,"months",5]]
println["You should begin solving the problem in " + format[t, "months", 5] + "."]
if t<0 days
   println["Since this is negative, you should begin now."]
else
{
   println["Computers will be " + format[factor, 1, 6] + " times faster then."]
   println["The problem will then take " + format[tt, "months", 5] + " to solve."]
   println["The problem will be completed " + format[t+tt, "months", 5] + " from now."]
   println["This is a savings of " + format[r-(t+tt), "months", 5] + "."]
}


Download or view mooreslaw.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 20218 days, 0 hours, 10 minutes ago.