Commit 042cf0be authored by Sebastian Graf's avatar Sebastian Graf

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
parent 44fc21a3
......@@ -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
......
......@@ -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
......
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
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