一个关于haskell程序性能的问题

瀏覽次數:32 次
跳到第一則未讀訊息

Yu Changyuan

未讀,
2014年11月8日 清晨7:20:412014/11/8
收件者:shlug
最近碰到一个关于haskell性能的问题,觉得有点奇怪。
程序的功能是简单的处理文本,但是花的时间和文本的长度不呈线性关系。
后来改了版,呈线性了,但不知道为什么,求高手解释。

先上图:

http://showterm.io/973fe885bb3f45ea09e6f#fast


生成测试文本的代码如下:

http://lpaste.net/113931

处理的代码如下:

http://lpaste.net/113932

修改好的代码如下:

http://lpaste.net/113933



--
Best regards,
Changyuan

Yu Changyuan

未讀,
2014年11月8日 上午10:27:052014/11/8
收件者:shlug
做了一个更加容易看明白的版本:
http://lpaste.net/113940

想知道代码里面的genSample为什么计算复杂度不是O(N)的。
--
Best regards,
Changyuan

Chaos Eternal

未讀,
2014年11月8日 上午10:41:052014/11/8
收件者:sh...@googlegroups.com
我就想知道 为啥刚才那个链接直接点是去wx.qq.com
> --
> -- You received this message because you are subscribed to the Google Groups
> Shanghai Linux User Group group. To post to this group, send email to
> sh...@googlegroups.com. To unsubscribe from this group, send email to
> shlug+un...@googlegroups.com. For more options, visit this group at
> https://groups.google.com/d/forum/shlug?hl=zh-CN
> ---
> 您收到此邮件是因为您订阅了Google网上论坛中的“Shanghai Linux User Group”论坛。
> 要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到shlug+un...@googlegroups.com
> 要查看更多选项,请访问https://groups.google.com/d/optout

Ray Song

未讀,
2014年11月8日 中午12:40:052014/11/8
收件者:Yu Changyuan、shlug
length x >= 5 每次對 genSample 求值都會執行,時間複雜度是行數的平方階的
>--
>-- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
>---
>您收到此邮件是因为您订阅了 Google 网上论坛的“Shanghai Linux User Group”论坛。
>要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到shlug+un...@googlegroups.com
>要查看更多选项,请访问 https://groups.google.com/d/optout

--
Ray
http://maskray.me
回覆所有人
回覆作者
轉寄
0 則新訊息