reset password
Author Message
gchan10
Posts: 27
Posted 11:05 Feb 17, 2019 |

Hi all,

Under the most optimal circumstances, what would be the expected performance of the Haskell code for the first part?

Thanks.

kmarlis
Posts: 35
Posted 11:07 Feb 17, 2019 |

Which implementation do you mean by the first part? 

gchan10
Posts: 27
Posted 11:21 Feb 17, 2019 |

Sorry, I meant all of the code we were expected to translate to Haskell in the Python notebook. So the question is, after we translate the code in the notebook from Python to Haskell, what would the expected performance of the Haskell code be? Thanks again.

kmarlis
Posts: 35
Posted 11:26 Feb 17, 2019 |

Oh for every implementation? For me, they are similar in scale to Python, that is fib_top_down_iter without any optimization performs much worse than the others. Does that help?

gchan10
Posts: 27
Posted 11:34 Feb 17, 2019 |

What about the average runtime of the program? Like, how long did it take to execute in seconds for each part?

Edit: BTW it did help, thank you.

Last edited by gchan10 at 11:36 Feb 17, 2019.
rabbott
Posts: 1649
Posted 12:26 Feb 17, 2019 |

My Haskell version of fib_top_down_rec 32 ran in about 3 sec, i.e., slower than Python.

My Haskell version of fib_top_down_iter_v2 32 ran in about 5 sec, i.e., significantly faster than Python. (This is the version with the cleaner stack elements. The Python version of that ran in about 13 sec, rather than 15 sec for the less clean version.)

> fib_top_down_rec 32
2178309
(2.74 secs, 840,639,384 bytes)


> fib_top_down_iter_v2 32
2178309
(5.07 secs, 3,677,039,280 bytes)

 

Last edited by rabbott at 14:22 Feb 17, 2019.
jungsoolim
Posts: 38
Posted 20:47 Feb 17, 2019 |

With cache, it takes 0.01 sec while my fib_top_down_iter takes over 45 seconds!

ghci> fib_top_down_iter_with_cache 32
([(32,2178309),(31,1346269),(30,832040),(29,514229),(28,317811),(27,196418),(26,121393),(25,75025),(24,46368),(23,28657),(22,17711),(21,10946),(20,6765),(19,4181),(18,2584),(17,1597),(16,987),(15,610),(14,377),(13,233),(12,144),(11,89),(10,55),(9,34),(8,21),(7,13),(6,8),(5,5),(4,3),(3,2),(1,1),(2,1)],[],[I 2178309])
(0.01 secs, 662,992 bytes)
ghci> 

Thanks!