next up previous
Next: Graphs Up: Accompanying material for: A Previous: One-dimensional bin packing

Some simple benchmarks


>  import System

>  import BinPacking
>  import Random
>  import Basic
>  import Printf


>  small, medium, big    :: Int -> [Double]

>  small  n              =  items n (0.01, 0.1)
>  medium n              =  items n (0.01, 0.5)  
>  big    n              =  items n (0.01, 1.0)


>  items                 :: Int -> (DoubleDouble) -> [Double]

>  items n range         =  take n (randomRs range (mkStdGen 19061997))


>  packFirstFitIO        :: String -> [Item] -> IO ()

>  packFirstFitIO q items=  printf "%7i bins for %7i %-6s items"
>                                  [Int b, Int i, String q]
>    where b             =  length (packFirstFit' items)
>          i             =  length items


>  main                  :: IO ()

>  main                  =  do args <- getArgs
>                              let n = noOfItems 1000 args
>                              packFirstFitIO "small"  (small  n)
>                              packFirstFitIO "medium" (medium n)
>                              packFirstFitIO "big"    (big    n)


>  noOfItems             :: Int -> [String] -> Int

>  noOfItems def [s]     =  readWithDefault def s
>  noOfItems def _       =  def


next up previous
Next: Graphs Up: Accompanying material for: A Previous: One-dimensional bin packing
Ralf Hinze 2001-03-20