Skip to content

Commit e32322c

Browse files
committed
Add make o
1 parent fe82eb5 commit e32322c

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ inputs/
55

66
# Answers
77
answers/
8+
9+
# Temporary build files generated, say, by `make o`
10+
out/

Makefile

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
default: example
22

3-
.PHONY: example read run test watch verify
3+
.PHONY: example read run test watch verify o clean
44

55
example:
66
@n=`ls -t *.hs | head -1 | cut -f1 -d.`; \
@@ -43,3 +43,17 @@ verify:
4343
cat $$in | runghc $$hs && \
4444
echo "(`cat answers/$$n-a`,`cat answers/$$n-b`)" ;\
4545
done
46+
47+
o:
48+
@n=`ls -t *.hs | head -1 | cut -f1 -d.`; \
49+
in="inputs/$$n"; \
50+
hs=`ls -t *.hs | head -1`; \
51+
mkdir -p out && \
52+
echo "ghc -O -outputdir out -o out/$$n $$hs" && \
53+
echo "cat $$in | time ./out/$$n" && \
54+
ghc -O -outputdir out -o out/$$n $$hs && \
55+
cat $$in | time -h ./out/$$n && \
56+
echo "(`cat answers/$$n-a`,`cat answers/$$n-b`)"
57+
58+
clean:
59+
rm -rf out

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,16 @@ Other commands:
1818
- `make watch` – same as `make`, but start a fswatch to automatically re-run
1919
it whenever the .hs file is changed.
2020
- `make verify` - Run `make test`, but for all days so far, in reverse.
21+
- `make o` - same as `make test`, but first compile the .hs file using GHC
22+
with optimizations enabled, and also print timings. To remove these, use
23+
`make clean`.
2124

2225
All of these are wrappers around the basic pattern of
2326

2427
cat somefile | runghc xx.hs
28+
29+
Some of the solutions are done in shell scripts. To run these, the filename
30+
needs to be passed to the script instead of passing the input via stdin (this is
31+
to keep the scripts simple – reading stdin in a script isn't a snap):
32+
33+
./xx.sh somefile

0 commit comments

Comments
 (0)