<span style="font-family: courier new,monospace;">> I would expect my (well, I</span><span style="font-family: courier new,monospace;"> didn't invent it) to work better on something that didn't have this</span><span style="font-family: courier new,monospace;"> unique structure, such as:</span><br>
> test 0 = Var 0<br>> test n | even n = Or (Var n) (test (n-1))<br>> | otherwise = And (test (n-1)) (Var n)<br>
<br>
<span style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">for some reason</span> this still does not perform as well as it should o__O<br>I think function composition might somehow be the bottleneck behind this.<br>
<br></span><span style="font-family: courier new,monospace;">--with<br>plong 0 = Var 0<br>plong n | even n = Or (Var n) (plong (n-1))<br> | otherwise = And (plong (n-1)) (Var n)<br><br>--and n = 1000000<br><br>
sert@elite:~/workspace/Haskell-1/bin$ time ./theResult sert</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">1000001</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">real 0m0.692s</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">user 0m0.624s</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">sys 0m0.040s</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"><br>sert@elite:~/workspace/Haskell-1/bin$ time ./theResult sert</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">1000001</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">real 0m0.696s</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">user 0m0.644s</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">sys 0m0.036s</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"><br>sert@elite:~/workspace/Haskell-1/bin$ time ./theResult sert</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">1000001</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">real 0m0.840s</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">user 0m0.744s</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">sys 0m0.052s</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"><br>sert@elite:~/workspace/Haskell-1/bin$ time ./theResult bromage</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">1000001</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">real 0m1.561s</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">user 0m1.360s</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">sys 0m0.100s</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"><br>sert@elite:~/workspace/Haskell-1/bin$ time ./theResult bromage</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">1000001</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">real 0m1.692s</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">user 0m1.392s</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">sys 0m0.136s</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"><br>sert@elite:~/workspace/Haskell-1/bin$ time ./theResult bromage</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">1000001</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">real 0m1.959s</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">user 0m1.580s</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">sys 0m0.116s</span><br style="font-family: courier new,monospace;">
<br><span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;">Best Regards,<br>Cetin Sert<br></span><br><div><span class="gmail_quote">On 21/02/2008, <b class="gmail_sendername"><a href="mailto:ajb@spamcop.net">ajb@spamcop.net</a></b> <<a href="mailto:ajb@spamcop.net">ajb@spamcop.net</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
G'day all.<br> <br> Quoting Cetin Sert <<a href="mailto:cetin.sert@gmail.com">cetin.sert@gmail.com</a>>:<br> <br> <br>> It is astonishing to see that your version actually performs the worst (at<br> > least on my machine).<br>
<br> <br>On your example, I'm not surprised:<br> <br><br> > plong 0 = Var 0<br> > plong n | even n = Or (Var n) (plong (n-1))<br> > | otherwise = And (Var n) (plong (n-1))<br> <br> <br>This is effectively a singly linked list. I would expect my (well, I<br>
didn't invent it) to work better on something that didn't have this<br> unique structure, such as:<br> <br> test 0 = Var 0<br> test n | even n = Or (Var n) (test (n-1))<br> | otherwise = And (test (n-1)) (Var n)<br>
<br><br> Cheers,<br> Andrew Bromage<br> _______________________________________________<br> Haskell-Cafe mailing list<br> <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br>