Commit 551b4154 authored by simonmar's avatar simonmar

[project @ 2001-03-02 11:44:24 by simonmar]

Add a reasonable Int vs. Integer benchmark.
parent 1a78fbf1
module Main (main) where
import System
main = do
--runalltests 1 20 10000 1 20 10000
--runalltests (-1000000) 4001 1000000 (-1000000) 4001 1000000
runalltests (-2100000000) 4000001 2100000000 (-2100000000) 4000001 2100000000
--[_1,_2,_3] <- getArgs
--let astart = read _1; astep = read _2; alim = read _3
--runalltests astart astep alim astart astep alim
runalltests
:: Integer -> Integer -> Integer
-> Integer -> Integer -> Integer
-> IO ()
runalltests astart astep alim bstart bstep blim = do
runbench (+) (+) "(+)" astart astep alim astart astep alim
runbench (-) (-) "(-)" astart astep alim astart astep alim
runbench (*) (*) "(*)" astart astep alim astart astep alim
runbench div div "div" astart astep alim astart astep alim
runbench mod mod "mod" astart astep alim astart astep alim
runbench quot quot "quot" astart astep alim astart astep alim
runbench rem rem "rem" astart astep alim astart astep alim
runbench gcd gcd "gcd" astart astep alim astart astep alim
runbench lcm lcm "lcm" astart astep alim astart astep alim
runbench (==) (==) "(==)" astart astep alim astart astep alim
runbench (<) (<) "(<)" astart astep alim astart astep alim
runbench (<=) (<=) "(<=)" astart astep alim astart astep alim
runbench (>) (>) "(>)" astart astep alim astart astep alim
runbench (>=) (>=) "(>=)" astart astep alim astart astep alim
runbench
:: (Integer -> Integer -> a)
-> (Int -> Int -> b)
-> String
-> Integer -> Integer -> Integer
-> Integer -> Integer -> Integer
-> IO ()
runbench jop iop opstr astart astep alim bstart bstep blim = do
intbench iop astart astep alim astart astep alim
integerbench jop astart astep alim astart astep alim
integerbench :: (Integer -> Integer -> a)
-> Integer -> Integer -> Integer
-> Integer -> Integer -> Integer
-> IO ()
integerbench op astart astep alim bstart bstep blim = do
seqlist ([ a `op` b
| a <- [ astart,astart+astep..alim ]
, b <- [ bstart,astart+bstep..blim ]])
return ()
intbench :: (Int -> Int -> a)
-> Integer -> Integer -> Integer
-> Integer -> Integer -> Integer
-> IO ()
intbench op astart astep alim bstart bstep blim = do
seqlist ([ a `op` b
| a <- [ fromInteger astart,fromInteger astart + fromInteger astep .. fromInteger alim ]
, b <- [ fromInteger bstart,fromInteger astart + fromInteger bstep .. fromInteger blim ]])
return ()
seqlist [] = return ()
seqlist (x:xs) = x `seq` seqlist xs
# -----------------------------------------------------------------------------
# $Id: Makefile,v 1.1 2001/03/02 11:44:24 simonmar Exp $
TOP = ../..
include $(TOP)/mk/boilerplate.mk
-include opts.mk
include $(TOP)/mk/target.mk
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