Last active
November 12, 2016 06:15
-
-
Save jtobin/6c90024deb7a9cffcb0f212f682f3297 to your computer and use it in GitHub Desktop.
such speed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Vector.Unboxed as U | |
import System.Random.MWC | |
main :: IO () | |
main = withSystemRandom . asGenIO $ \gen -> do | |
x <- uniformVector gen 10000000 :: IO (U.Vector Double) | |
print (U.sum x) | |
-- jtobin@castor:~/sandbox$ time ./Rand +RTS -s | |
-- 4999721.338394913 | |
-- 80,204,064 bytes allocated in the heap | |
-- 7,816 bytes copied during GC | |
-- 44,384 bytes maximum residency (1 sample(s)) | |
-- 727,888 bytes maximum slop | |
-- 78 MB total memory in use (0 MB lost due to fragmentation) | |
-- | |
-- Tot time (elapsed) Avg pause Max pause | |
-- Gen 0 1 colls, 0 par 0.000s 0.003s 0.0027s 0.0027s | |
-- Gen 1 1 colls, 0 par 0.000s 0.012s 0.0123s 0.0123s | |
-- | |
-- INIT time 0.000s ( 0.004s elapsed) | |
-- MUT time 0.176s ( 0.230s elapsed) | |
-- GC time 0.000s ( 0.015s elapsed) | |
-- EXIT time 0.000s ( 0.012s elapsed) | |
-- Total time 0.179s ( 0.261s elapsed) | |
-- | |
-- %GC time 0.2% (5.7% elapsed) | |
-- | |
-- Alloc rate 455,658,307 bytes per MUT second | |
-- | |
-- Productivity 99.8% of total user, 68.4% of total elapsed | |
-- | |
-- | |
-- real 0m0.296s <-------- close to C++ | |
-- user 0m0.179s | |
-- sys 0m0.055s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In comparison, compiling with -O2 seems to do a lot of aggressive transformation and inlining: