summaryrefslogtreecommitdiff
path: root/testsuite/tests/perf/should_run/UniqLoop.hs
blob: bd86ba336045c6e371a6fce5dbed354e3ff389f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{-# LANGUAGE BangPatterns #-}

module Main where

import GHC.Types.Unique.Supply
import GHC.Types.Unique

-- Generate a lot of uniques
main = do
    us <- mkSplitUniqSupply 'v'
    seq (churn us 10000000) (return ())

churn :: UniqSupply -> Int -> Int
churn !us 0 = getKey $ uniqFromSupply us
churn us n =
  let (!x,!us') = takeUniqFromSupply us
  in churn us' (n-1)