packages feed

squeeze-1.0.2.2: src/Squeeze/Test/Performance.hs

{-
	Copyright (C) 2011 Dr. Alistair Ward

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
-}
{- |
 [@AUTHOR@]	Dr. Alistair Ward

 [@DESCRIPTION@]	Defines a performance-test, based on randomly generated /virtual/ files.
-}

module Squeeze.Test.Performance(
-- * Functions
	run
) where

import			Control.Arrow((&&&))
import qualified	Factory.Math.Probability
import qualified	Squeeze.Data.CommandOptions	as Data.CommandOptions
import qualified	Squeeze.Data.FileCombination	as Data.FileCombination
import qualified	Squeeze.Squeeze			as Squeeze
import qualified	System.Random

{- |
	* Find the best-fit, into the available space,
	using a set composed from the specified number of /virtual/ files.

	* The files have a random size, conforming to the requested distribution.

	* The generated file-name, arbitrarily reflects its size.
-}
run :: (RealFrac ratio, RealFloat f, System.Random.Random f)
	=> Data.CommandOptions.CommandOptions ratio
	-> Int						-- ^ The number of /virtual/ files to randomly generate.
	-> Factory.Math.Probability.DiscreteDistribution f
	-> IO [Data.FileCombination.FileCombination]	-- ^ The results.
run commandOptions fileCount probabilityDistribution	= System.Random.getStdGen >>= Squeeze.findBestFitM commandOptions . map (id &&& show) . Factory.Math.Probability.generateDiscretePopulation fileCount probabilityDistribution