Here is an updated version using Data.Array.Unboxed <a href="http://ideone.com/YXuVL">http://ideone.com/YXuVL</a><br>And the profile <a href="http://hpaste.org/49940">http://hpaste.org/49940</a><br><br>Still taking 5+ minutes...<br>
<br>Chris<br><br><div class="gmail_quote">On Sun, Aug 7, 2011 at 5:20 PM, Daniel Fischer <span dir="ltr"><<a href="mailto:daniel.is.fischer@googlemail.com">daniel.is.fischer@googlemail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Sunday 07 August 2011, 10:52:20, Max Bolingbroke wrote:<br>
> In short I don't see how to get further without changing the algorithm<br>
> or doing some hacks like manual unrolling. Maybe someone else has some<br>
> ideas?<br>
<br>
</div>Well, the C# implementation uses arrays for lookup while the Haskell<br>
version uses list lookups<br>
<br>
in (tens !! fromIntegral t) ++ wordify x<br>
<br>
and case'd functions<br>
<br>
lenTens 0 = 0<br>
lenTens 1 = 3<br>
lenTens 2 = 6<br>
lenTens 3 = 6<br>
lenTens 4 = 5<br>
lenTens 5 = 5<br>
lenTens 6 = 5<br>
lenTens 7 = 7<br>
lenTens 8 = 6<br>
lenTens 9 = 6<br>
<br>
wordify is only called once at the end, so that should not have a<br>
measurable impact, but the lenXXXs might.<br>
I'm not sure what<br>
<br>
CaseLen.$wlenTens :: <a href="http://GHC.Prim.Int#" target="_blank">GHC.Prim.Int#</a> -> <a href="http://GHC.Prim.Int#" target="_blank">GHC.Prim.Int#</a><br>
[GblId,<br>
Arity=1,<br>
Str=DmdType L,<br>
Unf=Unf{Src=<vanilla>, TopLvl=True, Arity=1, Value=True,<br>
ConLike=True, Cheap=True, Expandable=True,<br>
Guidance=IF_ARGS [12] 11 0}]<br>
CaseLen.$wlenTens =<br>
\ (ww_shY :: <a href="http://GHC.Prim.Int#" target="_blank">GHC.Prim.Int#</a>) -><br>
case ww_shY of _ {<br>
__DEFAULT -><br>
CaseLen.lenTens1<br>
`cast` (CoUnsafe <a href="http://GHC.Types.Int" target="_blank">GHC.Types.Int</a> <a href="http://GHC.Prim.Int#" target="_blank">GHC.Prim.Int#</a><br>
:: <a href="http://GHC.Types.Int" target="_blank">GHC.Types.Int</a> ~ <a href="http://GHC.Prim.Int#" target="_blank">GHC.Prim.Int#</a>);<br>
0 -> 0;<br>
1 -> 3;<br>
2 -> 6;<br>
3 -> 6;<br>
4 -> 5;<br>
5 -> 5;<br>
6 -> 5;<br>
7 -> 7;<br>
8 -> 6;<br>
9 -> 6<br>
}<br>
<br>
means at a lower level, but it's certainly worth trying out whether an<br>
unboxed array lookup is faster.<br>
</blockquote></div><br>