SHARE
TWEET

Untitled

a guest Sep 18th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module Main where
  2.  
  3. import FastString
  4. import Control.Exception
  5. import Control.Monad
  6. import System.Mem
  7. import FastStringBench2
  8. import FastStringEnv
  9. import Module
  10. import Data.IORef
  11.  
  12. mkString :: Int -> (A, Int)
  13. mkString n = (A (mkFastString (show n <> "test-string")), n)
  14.  
  15. data A = A FastString
  16.  
  17. instance HasFastString A where
  18.   getFastString (A fs) = (mkFastString "a") `appendFS` fs
  19.  
  20.  
  21. main = do
  22.   forM_ [0..5] $ \i -> do
  23.     print i
  24.     let n = 1000000
  25.     let ss = map mkString [i..i + 1000000]
  26.     let env = mkFsEnv ss
  27.     c <- readIORef fastStringGcCounter
  28.     print c
  29.     forM_ [i .. i + 1000000] $ \i -> do
  30.       let (key, _) = mkString i
  31.       evaluate $ lookupFsEnv_NF env key
  32.     performGC
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top