[commit: nofib] master: Compare results of compress by hashing (042cf0b)

git at git.haskell.org git at git.haskell.org
Wed Dec 26 13:15:39 UTC 2018


Repository : ssh://git@git.haskell.org/nofib

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/042cf0be9e6f78a3b1474b568350916575202719/nofib

>---------------------------------------------------------------

commit 042cf0be9e6f78a3b1474b568350916575202719
Author: Sebastian Graf <sgraf1337 at gmail.com>
Date:   Wed Dec 26 13:45:33 2018 +0100

    Compare results of compress by hashing
    
    Summary:
    We don't want the result in the repo as it's a sizeable binary file that
    doesn't compress well.
    
    Storing the output file in the repository becomes infeasible for large
    inputs. There are two possible remedies:
    
    1. Generate the result files during `make boot` (Phab:D5426). We
       discovered some drawbacks (like missing dependency files to build
       `compress` during boot) to this approach which make it infeasible.
    2. Shrink the output files, for example by hashing the string that we would
       normally output and compare that instead.
    
    This patch implements the second alternative. This somewhat distorts the
    runtime profile, so we might want to consider doing hashing within the
    benchmark runner in the future.
    
    Test Plan: make boot
    
    Reviewers: AndreasK, nomeata, O26 nofib, osa1
    
    Reviewed By: AndreasK, osa1
    
    Subscribers: osa1
    
    Differential Revision: https://phabricator.haskell.org/D5469


>---------------------------------------------------------------

042cf0be9e6f78a3b1474b568350916575202719
 .gitignore                        |   1 -
 real/compress/Main.hs             |   8 ++++++--
 real/compress/Makefile            |   9 ++-------
 real/compress/compress.faststdout | Bin 94848 -> 19 bytes
 real/compress/compress.stdout     |   1 +
 5 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/.gitignore b/.gitignore
index c69af58..f1fae44 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,7 +34,6 @@ real/bspt/bspt
 real/cacheprof/cacheprof
 real/compress/compress
 real/compress/compress.stdin
-real/compress/compress.stdout
 real/compress2/compress2
 real/compress2/compress2.stdin
 real/compress2/compress2.stdout
diff --git a/real/compress/Main.hs b/real/compress/Main.hs
index 28ff58c..ec43fbb 100644
--- a/real/compress/Main.hs
+++ b/real/compress/Main.hs
@@ -16,13 +16,17 @@ module Main (main) where
 import Defaults
 import BinConv	  -- binary conversion routines
 import Encode     -- coding routine
+import Data.Char
+import Data.List (foldl')
 import System.IO
 
+hash :: String -> Int
+hash = foldl' (\acc c -> ord c + acc*31) 0
+
 main = do
   hSetBinaryMode stdin  True
-  hSetBinaryMode stdout True
   inp <- getContents
-  putStr (compress inp)
+  print (hash (compress inp))
 
 {- To compress a string we first encode it, then convert it to n-bit binaries
  - convert back to decimal as ascii-bit values and then to characters
diff --git a/real/compress/Makefile b/real/compress/Makefile
index f366d2c..ba4074e 100644
--- a/real/compress/Makefile
+++ b/real/compress/Makefile
@@ -1,20 +1,15 @@
 TOP = ../..
 include $(TOP)/mk/boilerplate.mk
 
-SRC_RUNTEST_OPTS += -stdout-binary
-
 SRCS = BinConv.hs BinTest.hs Decode.hs Defaults.hs Encode.hs Main.hs PTTrees.hs Uncompress.hs
 
-CLEAN_FILES += compress.stdin compress.stdout
+CLEAN_FILES += compress.stdin
 
 Lzw_HC_OPTS = -cpp
 
 include $(TOP)/mk/target.mk
 
-boot :: compress.stdin compress.faststdin compress.stdout
+boot :: compress.stdin
 
 compress.stdin : compress.faststdin
 	cat compress.faststdin *.hs *.c compress.faststdin *.hs *.c compress.faststdin > compress.stdin
-
-compress.stdout : compress.stdin compress
-	./compress < compress.stdin > compress.stdout
diff --git a/real/compress/compress.faststdout b/real/compress/compress.faststdout
index 3bfe8cb..ac69d34 100644
Binary files a/real/compress/compress.faststdout and b/real/compress/compress.faststdout differ
diff --git a/real/compress/compress.stdout b/real/compress/compress.stdout
new file mode 100644
index 0000000..86e4101
--- /dev/null
+++ b/real/compress/compress.stdout
@@ -0,0 +1 @@
+-172666309241294456



More information about the ghc-commits mailing list