Skip to content

Commit 3a541f1

Browse files
Merge pull request #73 from chrissimpkins/dev
v4.0.0
2 parents d31cc55 + 9e6ff20 commit 3a541f1

File tree

197 files changed

+1014
-393
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+1014
-393
lines changed

.travis.yml

+12-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ matrix:
3434
language: generic
3535
osx_image: xcode11 # Python 3.7.4 running on macOS 10.14.4
3636
before_install:
37-
- brew install pngcheck
37+
- export HOMEBREW_NO_INSTALL_CLEANUP=1 && brew install pngcheck
3838
install:
3939
- make build-dependencies
4040
- make install-executable
@@ -56,6 +56,17 @@ matrix:
5656
script:
5757
- flake8 --ignore=E501,W503,E121,E123,E126,E226,E24,E704,W503,W504 src/crunch.py
5858
- shellcheck --exclude=2046 src/*.sh
59+
- name: "Benchmarks"
60+
python: 3.7
61+
env: TOX_ENV=py37
62+
dist: xenial
63+
install:
64+
- pip install --upgrade numpy
65+
install:
66+
- make build-dependencies
67+
- make install-executable
68+
script:
69+
- make benchmark
5970

6071
# The following prevents Travis from running CI on pull requests that come from a
6172
# branch in the same repository. Without this, it will run the same CI for the

CHANGELOG.md

+20

LICENSE.md

+1-1

Makefile

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11

2+
benchmark:
3+
cd benchmarks && $(MAKE) $@
4+
25
build-dependencies:
36
src/install-dependencies.sh
47

8+
clean:
9+
rm benchmarks/img/*-crunch.png
10+
11+
dist:
12+
./dmg-builder.sh
13+
14+
dist-homebrew:
15+
cask-repair crunch
16+
517
install-executable:
618
sudo cp src/crunch.py /usr/local/bin/crunch
719
@echo " "
@@ -37,7 +49,7 @@ test-coverage:
3749

3850
test-python:
3951
tox
40-
flake8 --ignore=E501,W503,E121,E123,E126,E226,E24,E704,W503,W504 src/crunch.py
52+
flake8 --ignore=E501,W503,E121,E123,E126,E226,E24,E704,W503,W504,N806 src/crunch.py
4153

4254
test-shell:
4355
shellcheck --exclude=2046 src/*.sh
@@ -49,4 +61,5 @@ test-valid-png-output:
4961

5062
test: test-python test-shell test-valid-png-output
5163

52-
.PHONY: build-dependencies install-executable install-macos-service uninstall-executable uninstall-macos-service test test-coverage test-python test-shell test-valid-png-output
64+
65+
.PHONY: benchmark build-dependencies install-executable install-macos-service uninstall-executable uninstall-macos-service test test-coverage test-python test-shell test-valid-png-output dist

README.md

+15-13

benchmarks/Makefile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
benchmark:
3+
cd img && /usr/bin/time -p crunch *.png
4+
cd img && python3 bench.py
5+
6+
7+
.PHONY: benchmark

benchmarks/PngSuite.LICENSE

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
PngSuite
2+
--------
3+
4+
Permission to use, copy, modify and distribute these images for any
5+
purpose and without fee is hereby granted.
6+
7+
8+
(c) Willem van Schaik, 1996, 2011

benchmarks/README.md

+36

benchmarks/img/basi0g01.png

217 Bytes

benchmarks/img/basi0g02.png

154 Bytes

benchmarks/img/basi0g04.png

247 Bytes

benchmarks/img/basi0g08.png

254 Bytes

benchmarks/img/basi0g16.png

299 Bytes

benchmarks/img/basi2c08.png

315 Bytes

benchmarks/img/basi2c16.png

595 Bytes

benchmarks/img/basi3p01.png

132 Bytes

benchmarks/img/basi3p02.png

193 Bytes

benchmarks/img/basi3p04.png

327 Bytes

benchmarks/img/basi3p08.png

1.49 KB

benchmarks/img/basi4a08.png

214 Bytes

benchmarks/img/basi4a16.png

2.79 KB

benchmarks/img/basi6a08.png

361 Bytes

benchmarks/img/basi6a16.png

4.08 KB

benchmarks/img/basn0g01.png

164 Bytes

benchmarks/img/basn0g02.png

104 Bytes

benchmarks/img/basn0g04.png

145 Bytes

benchmarks/img/basn0g08.png

138 Bytes

benchmarks/img/basn0g16.png

167 Bytes

benchmarks/img/basn2c08.png

145 Bytes

benchmarks/img/basn2c16.png

302 Bytes

benchmarks/img/basn3p01.png

112 Bytes

benchmarks/img/basn3p02.png

146 Bytes

benchmarks/img/basn3p04.png

216 Bytes

benchmarks/img/basn3p08.png

1.26 KB

benchmarks/img/basn4a08.png

126 Bytes

benchmarks/img/basn4a16.png

2.15 KB

benchmarks/img/basn6a08.png

184 Bytes

benchmarks/img/basn6a16.png

3.35 KB

benchmarks/img/bench.py

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env python3
2+
3+
# ----------------------------------------
4+
#
5+
# Copyright (c) 2019 Christopher Simpkins
6+
# MIT license
7+
#
8+
# ---------------------------------------
9+
10+
11+
import glob
12+
import os
13+
14+
15+
def grouped(iterable, n):
16+
return zip(*[iter(iterable)] * n)
17+
18+
19+
paths = sorted(glob.glob("*.png"))
20+
21+
percent_list = []
22+
pre_size_list = []
23+
post_size_list = []
24+
25+
for path_a, path_b in grouped(paths, 2):
26+
if "-crunch" in path_a:
27+
post_path = path_a
28+
pre_path = path_b
29+
else:
30+
post_path = path_b
31+
pre_path = path_a
32+
33+
# assert that we are testing the correct pairs of files
34+
assert f"{pre_path[:-4]}-crunch.png" == post_path
35+
36+
pre_size = os.path.getsize(pre_path)
37+
post_size = os.path.getsize(post_path)
38+
percent_size = (post_size / pre_size) * 100
39+
40+
percent_list.append(percent_size)
41+
pre_size_list.append(pre_size)
42+
post_size_list.append(post_size)
43+
44+
print(f"{post_path}: {percent_size:.2f}%")
45+
46+
47+
mean = sum(percent_list) / len(percent_list)
48+
total_initial_size = sum(pre_size_list)
49+
total_final_size = sum(post_size_list)
50+
delta = total_initial_size - total_final_size
51+
52+
print(f"\nInitial:\t{total_initial_size:>8} B")
53+
print(f"Final: \t{total_final_size:>8} B")
54+
print(f"Delta: -{delta} B")
55+
print(f"Mean: {mean:.2f}%")
56+
try:
57+
import numpy as np
58+
59+
a = np.array(percent_list)
60+
stdev = np.std(a, dtype=np.float64)
61+
print(f"SD: {stdev:.2f}%")
62+
except Exception:
63+
pass

benchmarks/img/bgai4a08.png

214 Bytes

benchmarks/img/bgai4a16.png

2.79 KB

benchmarks/img/bgan6a08.png

184 Bytes

benchmarks/img/bgan6a16.png

3.35 KB

benchmarks/img/bgbn4a08.png

140 Bytes

benchmarks/img/bggn4a16.png

2.17 KB

benchmarks/img/bgwn6a08.png

202 Bytes

benchmarks/img/bgyn6a16.png

3.37 KB

benchmarks/img/ccwn2c08.png

1.48 KB

benchmarks/img/ccwn3p08.png

1.52 KB

benchmarks/img/cdfn2c08.png

404 Bytes

benchmarks/img/cdhn2c08.png

344 Bytes

benchmarks/img/cdsn2c08.png

232 Bytes

benchmarks/img/cdun2c08.png

724 Bytes

benchmarks/img/ch1n3p04.png

258 Bytes

benchmarks/img/ch2n3p08.png

1.77 KB

benchmarks/img/cm0n0g04.png

292 Bytes

benchmarks/img/cm7n0g04.png

292 Bytes

benchmarks/img/cm9n0g04.png

292 Bytes

benchmarks/img/cs3n2c16.png

214 Bytes

benchmarks/img/cs3n3p08.png

259 Bytes

benchmarks/img/cs5n2c08.png

186 Bytes

benchmarks/img/cs5n3p08.png

271 Bytes

benchmarks/img/cs8n2c08.png

149 Bytes

benchmarks/img/cs8n3p08.png

256 Bytes

benchmarks/img/ct0n0g04.png

273 Bytes

benchmarks/img/ct1n0g04.png

792 Bytes

benchmarks/img/cten0g04.png

742 Bytes

benchmarks/img/ctfn0g04.png

716 Bytes

benchmarks/img/ctgn0g04.png

1.15 KB

benchmarks/img/cthn0g04.png

1.24 KB

benchmarks/img/ctjn0g04.png

941 Bytes

benchmarks/img/ctzn0g04.png

753 Bytes

benchmarks/img/exif2c08.png

1.75 KB

benchmarks/img/f00n0g08.png

319 Bytes

benchmarks/img/f00n2c08.png

2.42 KB

benchmarks/img/f01n0g08.png

321 Bytes

benchmarks/img/f01n2c08.png

1.15 KB

benchmarks/img/f02n0g08.png

355 Bytes

benchmarks/img/f02n2c08.png

1.69 KB

benchmarks/img/f03n0g08.png

389 Bytes

benchmarks/img/f03n2c08.png

1.26 KB

benchmarks/img/f04n0g08.png

269 Bytes

benchmarks/img/f04n2c08.png

985 Bytes

benchmarks/img/f99n0g04.png

426 Bytes

benchmarks/img/g03n0g16.png

345 Bytes

benchmarks/img/g03n2c08.png

370 Bytes

benchmarks/img/g03n3p04.png

214 Bytes

benchmarks/img/g04n0g16.png

363 Bytes

benchmarks/img/g04n2c08.png

377 Bytes

benchmarks/img/g04n3p04.png

219 Bytes

benchmarks/img/g05n0g16.png

339 Bytes

benchmarks/img/g05n2c08.png

350 Bytes

benchmarks/img/g05n3p04.png

206 Bytes

benchmarks/img/g07n0g16.png

321 Bytes

benchmarks/img/g07n2c08.png

340 Bytes

benchmarks/img/g07n3p04.png

207 Bytes

benchmarks/img/g10n0g16.png

262 Bytes

benchmarks/img/g10n2c08.png

285 Bytes

benchmarks/img/g10n3p04.png

214 Bytes

benchmarks/img/g25n0g16.png

383 Bytes

benchmarks/img/g25n2c08.png

405 Bytes

benchmarks/img/g25n3p04.png

215 Bytes

benchmarks/img/oi1n0g16.png

167 Bytes

benchmarks/img/oi1n2c16.png

302 Bytes

benchmarks/img/oi2n0g16.png

179 Bytes

benchmarks/img/oi2n2c16.png

314 Bytes

benchmarks/img/oi4n0g16.png

203 Bytes

benchmarks/img/oi4n2c16.png

338 Bytes

benchmarks/img/oi9n0g16.png

1.25 KB

benchmarks/img/oi9n2c16.png

2.97 KB

benchmarks/img/pp0n2c16.png

962 Bytes

benchmarks/img/pp0n6a08.png

818 Bytes

benchmarks/img/ps1n0g08.png

1.42 KB

benchmarks/img/ps1n2c16.png

1.58 KB

benchmarks/img/ps2n0g08.png

2.27 KB

benchmarks/img/ps2n2c16.png

2.43 KB

benchmarks/img/s01i3p01.png

113 Bytes

benchmarks/img/s01n3p01.png

113 Bytes

benchmarks/img/s02i3p01.png

114 Bytes

benchmarks/img/s02n3p01.png

115 Bytes

benchmarks/img/s03i3p01.png

118 Bytes

benchmarks/img/s03n3p01.png

120 Bytes

benchmarks/img/s04i3p01.png

126 Bytes

benchmarks/img/s04n3p01.png

121 Bytes

benchmarks/img/s05i3p02.png

134 Bytes

benchmarks/img/s05n3p02.png

129 Bytes

benchmarks/img/s06i3p02.png

143 Bytes

benchmarks/img/s06n3p02.png

131 Bytes

benchmarks/img/s07i3p02.png

149 Bytes

benchmarks/img/s07n3p02.png

138 Bytes

benchmarks/img/s08i3p02.png

149 Bytes

benchmarks/img/s08n3p02.png

139 Bytes

benchmarks/img/s09i3p02.png

147 Bytes

benchmarks/img/s09n3p02.png

143 Bytes

benchmarks/img/s32i3p04.png

355 Bytes

benchmarks/img/s32n3p04.png

263 Bytes

benchmarks/img/s33i3p04.png

385 Bytes

benchmarks/img/s33n3p04.png

329 Bytes

benchmarks/img/s34i3p04.png

349 Bytes

benchmarks/img/s34n3p04.png

248 Bytes

benchmarks/img/s35i3p04.png

399 Bytes

benchmarks/img/s35n3p04.png

338 Bytes

benchmarks/img/s36i3p04.png

356 Bytes

benchmarks/img/s36n3p04.png

258 Bytes

benchmarks/img/s37i3p04.png

393 Bytes

benchmarks/img/s37n3p04.png

336 Bytes

benchmarks/img/s38i3p04.png

357 Bytes

benchmarks/img/s38n3p04.png

245 Bytes

benchmarks/img/s39i3p04.png

420 Bytes

benchmarks/img/s39n3p04.png

352 Bytes

benchmarks/img/s40i3p04.png

357 Bytes

benchmarks/img/s40n3p04.png

256 Bytes

benchmarks/img/tbbn0g04.png

429 Bytes

benchmarks/img/tbbn2c16.png

1.99 KB

benchmarks/img/tbbn3p08.png

1.46 KB

benchmarks/img/tbgn2c16.png

1.99 KB

benchmarks/img/tbgn3p08.png

1.46 KB

benchmarks/img/tbrn2c08.png

1.59 KB

benchmarks/img/tbwn0g16.png

1.28 KB

benchmarks/img/tbwn3p08.png

1.46 KB

benchmarks/img/tbyn3p08.png

1.46 KB

benchmarks/img/tm3n3p02.png

116 Bytes

benchmarks/img/tp0n0g08.png

719 Bytes

benchmarks/img/tp0n2c08.png

1.56 KB

benchmarks/img/tp0n3p08.png

1.44 KB

benchmarks/img/tp1n3p08.png

1.45 KB

benchmarks/img/z00n2c08.png

3.1 KB

benchmarks/img/z03n2c08.png

232 Bytes

benchmarks/img/z06n2c08.png

224 Bytes

benchmarks/img/z09n2c08.png

224 Bytes

bin/Crunch.app/Contents/Info.plist

-60 Bytes
Binary file not shown.

bin/Crunch.app/Contents/MacOS/Crunch

-9.41 KB
Binary file not shown.
Binary file not shown.
-118 KB
Binary file not shown.

0 commit comments

Comments
 (0)