From 80c3d5ad531c96560a25f35323b538e6986e65f0 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Wed, 30 May 2012 16:04:17 +0100 Subject: Improve the size-change detection heuristics in the compare tool --- distrib/compare/compare.hs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'distrib') diff --git a/distrib/compare/compare.hs b/distrib/compare/compare.hs index 0e0e9f8306..0c6c4c4f39 100644 --- a/distrib/compare/compare.hs +++ b/distrib/compare/compare.hs @@ -16,13 +16,13 @@ import Tar -- * Check installed trees too -- * Check hashbangs --- Only size changes > sizeAbs are considered an issue -sizeAbs :: Integer -sizeAbs = 1000 - --- Only a size change of sizePercentage% or more is considered an issue -sizePercentage :: Integer -sizePercentage = 150 +sizeChangeThresholds :: [(Integer, -- Theshold only applies if one of + -- the files is at least this big + Integer)] -- Size changed if the larger file's + -- size is at least this %age of the + -- smaller file's size +sizeChangeThresholds = [( 1000, 150), + (50 * 1000, 110)] main :: IO () main = do args <- getArgs @@ -260,9 +260,12 @@ compareTarLine tl1 tl2 perms2 = tlPermissions tl2 size1 = tlSize tl1 size2 = tlSize tl2 - sizeChanged = abs (size1 - size2) > sizeAbs - && (((100 * size1) `div` size2) > sizePercentage || - ((100 * size2) `div` size1) > sizePercentage) + sizeMin = size1 `min` size2 + sizeMax = size1 `max` size2 + sizeChanged = any sizeChangeThresholdReached sizeChangeThresholds + sizeChangeThresholdReached (reqSize, percentage) + = (sizeMax >= reqSize) + && (((100 * sizeMax) `div` sizeMin) >= percentage) versionRE :: String versionRE = "([0-9]+(\\.[0-9]+)*)" -- cgit v1.2.1