[Haskell-cafe] Slow IO?
Don Stewart
dons at galois.com
Tue Sep 1 01:40:21 EDT 2009
Good work guys.
If you can abstract out a common function for lexing ints out of
bytestrings, we could add it to the bytestring-lexing package.
ekirpichov:
> Hm, on my machine Don's code has exactly the same performance my code above.
>
> Also, replacing the 'test' and 'parse' functions with this one
>
> add :: Int -> Int -> S.ByteString -> Int
> add k i s = fst $ S.foldl' f (i, 0) s
> where f (!i, !n) '\n' | n`divisibleBy`k = (i+1, 0)
> | otherwise = (i, 0)
> f (!i, !n) w = (i, 10*n+ord w-ord '0')
>
> increases performance by another 15% (0.675s vs 0.790s)
>
> 2009/9/1 Jason Dusek <jason.dusek at gmail.com>:
> > I've updated Don Stewart's solution to compile with the modern
> > ByteString libs. I'll be looking at ways to improve the
> > performance of the `bytestring-nums` package.
> >
> > --
> > Jason Dusek
> >
> >
> > http://github.com/jsnx/bytestring-nums/blob/d7de9db83e44ade9958fb3bfad0b29ede065b5dd/SPOJDons.hs
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> >
>
>
>
> --
> Eugene Kirpichov
> Web IR developer, market.yandex.ru
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
More information about the Haskell-Cafe
mailing list