showexpr can be accelerated by foldr #314
YuMingLiao
started this conversation in
General
Replies: 1 comment 2 replies
-
Good point! Do you wish to make a merge request? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Right now, function
tupleFolder
usesfoldl'
to O(n)(++)
.if
foldr
and O(1)(:)
is used, speed is up and space is saved.foldl_strict.hs
4,293,617,024 bytes allocated in the heap [0/1843]
433,526,736 bytes copied during GC
790,688 bytes maximum residency (2 sample(s))
118,624 bytes maximum slop
4 MiB total memory in use (0 MB lost due to fragmentation)
...
INIT time 0.000s ( 0.000s elapsed)
MUT time 2.671s ( 2.732s elapsed)
GC time 1.351s ( 1.379s elapsed)
EXIT time 0.000s ( 0.000s elapsed)
Total time 4.023s ( 4.111s elapsed)
foldr.hs
main = print $ foldr (:) [] [1..10000]
...
INIT time 0.000s ( 0.000s elapsed)
MUT time 0.005s ( 0.021s elapsed)
GC time 0.002s ( 0.002s elapsed)
EXIT time 0.000s ( 0.000s elapsed)
Total time 0.008s ( 0.023s elapsed)
Beta Was this translation helpful? Give feedback.
All reactions