-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unpacking in reverse #510
Comments
Maybe with |
I've been very confused by the
If I have a |
I suppose I have the same question/request about packing as well. We have |
I don't see any substantial time difference between forward/reverse unpacking, so I suppose you're right about import Criterion.Main
import qualified Data.Text as Text
forward = take 200 . Text.unpack
backward = take 200 . Text.foldr (:) []
main = defaultMain
[ bgroup "forward"
[ env (pure $ Text.replicate 1000 "abc") $ \t -> bench "1000" $ nf forward t
, env (pure $ Text.replicate 1000000 "abc") $ \t -> bench "1000000" $ nf forward t
, env (pure $ Text.replicate 1000000000 "abc") $ \t -> bench "1000000000" $ nf forward t
]
, bgroup "backward"
[ env (pure $ Text.replicate 1000 "abc") $ \t -> bench "1000" $ nf backward t
, env (pure $ Text.replicate 1000000 "abc") $ \t -> bench "1000000" $ nf backward t
, env (pure $ Text.replicate 1000000000 "abc") $ \t -> bench "1000000000" $ nf backward t
]
]
Perhaps all that I needed here was more clear documentation. |
I had a brainfart moment. For a lazy reverse-into-string function, right now, the best safe solution seems to be using Ideally, I think a better solution would be provided by |
The best way I've come up with so far to make a list that traverses a
Text
backwards is:Is there a way to make this substantially more efficient? Would it be worth adding to the library?
The text was updated successfully, but these errors were encountered: