Commit d724ce3c authored by David Feuer's avatar David Feuer Committed by David Feuer
Browse files

Add a perf test for deriving null

Deriving null even helps for a simple list-like type,
presumably because we don't perform the static argument
transformation. Adding this test before the null deriving
patch should give a proper baseline.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:
parent 4ed33975
{-# LANGUAGE DeriveFoldable #-}
module Main where
import Data.Semigroup
-- Just a list without any special fusion rules.
data List a = Nil | Cons a (List a) deriving Foldable
instance Semigroup (List a) where
Nil <> ys = ys
Cons x xs <> ys = Cons x (xs <> ys)
replicateList :: Int -> a -> List a
replicateList 0 x = Nil
replicateList n x = Cons x (replicateList (n - 1) x)
newtype ListList a = ListList (List (List a)) deriving Foldable
long :: Int -> Bool
long n = null $ ListList $ replicateList n Nil <> Cons (Cons () Nil) Nil
main :: IO ()
main = print $ long (10^(6 :: Int))
......@@ -526,3 +526,11 @@ test('T13218',
[stats_num_field('bytes allocated',
[ (wordsize(64), 152083704, 5) ]),
# 2017-04-02 152083704 w/o derived null
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment