Initial commit (squashed)
BIN
bench/1000px
Normal file
|
After Width: | Height: | Size: 96 KiB |
BIN
bench/100px
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
bench/2000px
Normal file
|
After Width: | Height: | Size: 175 KiB |
BIN
bench/200px
Normal file
|
After Width: | Height: | Size: 8.2 KiB |
BIN
bench/3000px
Normal file
|
After Width: | Height: | Size: 576 KiB |
BIN
bench/300px
Normal file
|
After Width: | Height: | Size: 51 KiB |
BIN
bench/4000px
Normal file
|
After Width: | Height: | Size: 2.1 MiB |
BIN
bench/500px
Normal file
|
After Width: | Height: | Size: 63 KiB |
BIN
bench/6000px
Normal file
|
After Width: | Height: | Size: 5.7 MiB |
BIN
bench/8000px
Normal file
|
After Width: | Height: | Size: 2.6 MiB |
38
bench/benchmark.py
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
import timeit
|
||||
import sys
|
||||
|
||||
IMAGE = sys.argv[1]
|
||||
COUNT = 20
|
||||
SIZE = 8
|
||||
|
||||
def print_result(method, time):
|
||||
print("%s_%s,%d" % (IMAGE, method, time / COUNT * 1000000000))
|
||||
|
||||
print_result("phash", timeit.timeit(
|
||||
setup="from imagehash import phash \n"
|
||||
"from PIL import Image",
|
||||
stmt="phash(Image.open('%s'), hash_size=%d)" % (IMAGE, SIZE),
|
||||
number=COUNT
|
||||
))
|
||||
|
||||
print_result("whash", timeit.timeit(
|
||||
setup="from imagehash import whash \n"
|
||||
"from PIL import Image",
|
||||
stmt="whash(Image.open('%s'), hash_size=%d, remove_max_haar_ll=False)" % (IMAGE, SIZE),
|
||||
number=COUNT
|
||||
))
|
||||
|
||||
print_result("dhash", timeit.timeit(
|
||||
setup="from imagehash import dhash \n"
|
||||
"from PIL import Image",
|
||||
stmt="dhash(Image.open('%s'), hash_size=%d)" % (IMAGE, SIZE),
|
||||
number=COUNT
|
||||
))
|
||||
|
||||
print_result("ahash", timeit.timeit(
|
||||
setup="from imagehash import average_hash \n"
|
||||
"from PIL import Image",
|
||||
stmt="average_hash(Image.open('%s'), hash_size=%d)" % (IMAGE, SIZE),
|
||||
number=COUNT
|
||||
))
|
||||
81
bench/results/bench.csv
Normal file
@@ -0,0 +1,81 @@
|
||||
100px_phash,1501752
|
||||
100px_whash,1191232
|
||||
100px_dhash,627767
|
||||
100px_ahash,559005
|
||||
200px_phash,1890701
|
||||
200px_whash,1705581
|
||||
200px_dhash,764158
|
||||
200px_ahash,773574
|
||||
300px_phash,3349884
|
||||
300px_whash,3585630
|
||||
300px_dhash,2165022
|
||||
300px_ahash,2138236
|
||||
500px_phash,8181995
|
||||
500px_whash,16893975
|
||||
500px_dhash,6583327
|
||||
500px_ahash,6129121
|
||||
1000px_phash,33332575
|
||||
1000px_whash,32719635
|
||||
1000px_dhash,22770614
|
||||
1000px_ahash,17089768
|
||||
2000px_phash,66180354
|
||||
2000px_whash,101643309
|
||||
2000px_dhash,55663749
|
||||
2000px_ahash,57924298
|
||||
3000px_phash,125681339
|
||||
3000px_whash,228129635
|
||||
3000px_dhash,138621595
|
||||
3000px_ahash,97757975
|
||||
4000px_phash,275259074
|
||||
4000px_whash,501619747
|
||||
4000px_dhash,207196780
|
||||
4000px_ahash,302886693
|
||||
6000px_phash,509748444
|
||||
6000px_whash,749504047
|
||||
6000px_dhash,510110532
|
||||
6000px_ahash,651134350
|
||||
8000px_phash,804032051
|
||||
8000px_whash,1561515488
|
||||
8000px_dhash,935896765
|
||||
8000px_ahash,797512191
|
||||
|
||||
100px_phash,156781
|
||||
100px_whash,173199
|
||||
100px_dhash,90662.8
|
||||
100px_ahash,101213
|
||||
200px_phash,700678
|
||||
200px_whash,859678
|
||||
200px_dhash,452687
|
||||
200px_ahash,387735
|
||||
300px_phash,1.25202e+06
|
||||
300px_whash,1.8245e+06
|
||||
300px_dhash,1.25765e+06
|
||||
300px_ahash,973228
|
||||
500px_phash,2.38869e+06
|
||||
500px_whash,1.1267e+07
|
||||
500px_dhash,2.17194e+06
|
||||
500px_ahash,2.2334e+06
|
||||
1000px_phash,5.74643e+06
|
||||
1000px_whash,1.16069e+07
|
||||
1000px_dhash,5.07346e+06
|
||||
1000px_ahash,2.5366e+06
|
||||
2000px_phash,2.65802e+07
|
||||
2000px_whash,6.72166e+07
|
||||
2000px_dhash,1.84348e+07
|
||||
2000px_ahash,8.71788e+06
|
||||
3000px_phash,4.03586e+07
|
||||
3000px_whash,8.8327e+07
|
||||
3000px_dhash,3.53093e+07
|
||||
3000px_ahash,1.79755e+07
|
||||
4000px_phash,8.40194e+07
|
||||
4000px_whash,4.82593e+08
|
||||
4000px_dhash,9.43476e+07
|
||||
4000px_ahash,6.51547e+07
|
||||
6000px_phash,2.28308e+08
|
||||
6000px_whash,4.19073e+08
|
||||
6000px_dhash,2.12647e+08
|
||||
6000px_ahash,2.03283e+08
|
||||
8000px_phash,2.38032e+08
|
||||
8000px_whash,1.19931e+09
|
||||
8000px_dhash,3.05067e+08
|
||||
8000px_ahash,2.73826e+08
|
||||
|
81
bench/results/bench2.csv
Normal file
@@ -0,0 +1,81 @@
|
||||
100px_phash,1546245
|
||||
100px_whash,1142629
|
||||
100px_dhash,422119
|
||||
100px_ahash,459319
|
||||
200px_phash,2289901
|
||||
200px_whash,1982601
|
||||
200px_dhash,877761
|
||||
200px_ahash,893851
|
||||
300px_phash,5754956
|
||||
300px_whash,4130921
|
||||
300px_dhash,2337779
|
||||
300px_ahash,3306587
|
||||
500px_phash,16423604
|
||||
500px_whash,25278172
|
||||
500px_dhash,13543857
|
||||
500px_ahash,12730359
|
||||
1000px_phash,38916426
|
||||
1000px_whash,43298265
|
||||
1000px_dhash,22826313
|
||||
1000px_ahash,23075597
|
||||
2000px_phash,108740058
|
||||
2000px_whash,130074288
|
||||
2000px_dhash,86906159
|
||||
2000px_ahash,82882133
|
||||
3000px_phash,157641043
|
||||
3000px_whash,194007627
|
||||
3000px_dhash,115356997
|
||||
3000px_ahash,167002746
|
||||
4000px_phash,320478682
|
||||
4000px_whash,611399093
|
||||
4000px_dhash,258676239
|
||||
4000px_ahash,278319008
|
||||
6000px_phash,663131052
|
||||
6000px_whash,968925343
|
||||
6000px_dhash,603457884
|
||||
6000px_ahash,590223791
|
||||
8000px_phash,968315239
|
||||
8000px_whash,2128619381
|
||||
8000px_dhash,810395862
|
||||
8000px_ahash,825277357
|
||||
|
||||
100px_phash,172159
|
||||
100px_whash,289971
|
||||
100px_dhash,114212
|
||||
100px_ahash,98125.5
|
||||
200px_phash,367338
|
||||
200px_whash,656732
|
||||
200px_dhash,249119
|
||||
200px_ahash,343462
|
||||
300px_phash,1.28685e+06
|
||||
300px_whash,1.39146e+06
|
||||
300px_dhash,1.14464e+06
|
||||
300px_ahash,900021
|
||||
500px_phash,2.22673e+06
|
||||
500px_whash,7.74973e+06
|
||||
500px_dhash,2.12625e+06
|
||||
500px_ahash,2.89128e+06
|
||||
1000px_phash,7.79976e+06
|
||||
1000px_whash,1.70092e+07
|
||||
1000px_dhash,7.78873e+06
|
||||
1000px_ahash,2.82737e+06
|
||||
2000px_phash,2.49954e+07
|
||||
2000px_whash,1.24924e+08
|
||||
2000px_dhash,4.11592e+07
|
||||
2000px_ahash,2.0187e+07
|
||||
3000px_phash,3.89911e+07
|
||||
3000px_whash,9.88339e+07
|
||||
3000px_dhash,3.39018e+07
|
||||
3000px_ahash,2.53518e+07
|
||||
4000px_phash,8.36112e+07
|
||||
4000px_whash,2.41845e+08
|
||||
4000px_dhash,4.09667e+07
|
||||
4000px_ahash,4.06429e+07
|
||||
6000px_phash,1.79905e+08
|
||||
6000px_whash,3.62966e+08
|
||||
6000px_dhash,1.73798e+08
|
||||
6000px_ahash,1.19691e+08
|
||||
8000px_phash,2.35173e+08
|
||||
8000px_whash,1.18053e+09
|
||||
8000px_dhash,2.61731e+08
|
||||
8000px_ahash,2.33739e+08
|
||||
|
81
bench/results/bench3.csv
Normal file
@@ -0,0 +1,81 @@
|
||||
100px_phash,2382869
|
||||
100px_whash,1521012
|
||||
100px_dhash,580412
|
||||
100px_ahash,603286
|
||||
200px_phash,1926447
|
||||
200px_whash,1768162
|
||||
200px_dhash,774964
|
||||
200px_ahash,771083
|
||||
300px_phash,3790657
|
||||
300px_whash,3626704
|
||||
300px_dhash,2067537
|
||||
300px_ahash,2069114
|
||||
500px_phash,10906352
|
||||
500px_whash,22738215
|
||||
500px_dhash,10272449
|
||||
500px_ahash,9595167
|
||||
1000px_phash,23141506
|
||||
1000px_whash,25170109
|
||||
1000px_dhash,14824129
|
||||
1000px_ahash,15091460
|
||||
2000px_phash,57189668
|
||||
2000px_whash,108344237
|
||||
2000px_dhash,62995725
|
||||
2000px_ahash,62746881
|
||||
3000px_phash,138799963
|
||||
3000px_whash,217013121
|
||||
3000px_dhash,106064767
|
||||
3000px_ahash,161430438
|
||||
4000px_phash,242516033
|
||||
4000px_whash,513381749
|
||||
4000px_dhash,244478546
|
||||
4000px_ahash,334389817
|
||||
6000px_phash,541641403
|
||||
6000px_whash,825888963
|
||||
6000px_dhash,458842570
|
||||
6000px_ahash,487875492
|
||||
8000px_phash,882104246
|
||||
8000px_whash,1805513081
|
||||
8000px_dhash,763400049
|
||||
8000px_ahash,717820524
|
||||
|
||||
100px_phash,216477
|
||||
100px_whash,242169
|
||||
100px_dhash,105712
|
||||
100px_ahash,115431
|
||||
200px_phash,473393
|
||||
200px_whash,599663
|
||||
200px_dhash,184172
|
||||
200px_ahash,206734
|
||||
300px_phash,886085
|
||||
300px_whash,1.17681e+06
|
||||
300px_dhash,758226
|
||||
300px_ahash,825329
|
||||
500px_phash,1.92917e+06
|
||||
500px_whash,7.30992e+06
|
||||
500px_dhash,2.67147e+06
|
||||
500px_ahash,2.45408e+06
|
||||
1000px_phash,5.96402e+06
|
||||
1000px_whash,9.16642e+06
|
||||
1000px_dhash,5.30646e+06
|
||||
1000px_ahash,2.40083e+06
|
||||
2000px_phash,1.54843e+07
|
||||
2000px_whash,4.93767e+07
|
||||
2000px_dhash,1.98073e+07
|
||||
2000px_ahash,1.07622e+07
|
||||
3000px_phash,3.11459e+07
|
||||
3000px_whash,6.19604e+07
|
||||
3000px_dhash,3.0431e+07
|
||||
3000px_ahash,1.78016e+07
|
||||
4000px_phash,7.47504e+07
|
||||
4000px_whash,2.19254e+08
|
||||
4000px_dhash,5.78558e+07
|
||||
4000px_ahash,4.9799e+07
|
||||
6000px_phash,1.67584e+08
|
||||
6000px_whash,3.67142e+08
|
||||
6000px_dhash,1.94565e+08
|
||||
6000px_ahash,1.40676e+08
|
||||
8000px_phash,2.0177e+08
|
||||
8000px_whash,1.36282e+09
|
||||
8000px_dhash,2.27323e+08
|
||||
8000px_ahash,2.25973e+08
|
||||
|
37
bench/run.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from subprocess import check_output, DEVNULL
|
||||
import csv
|
||||
|
||||
files = (
|
||||
"100px",
|
||||
"200px",
|
||||
"300px",
|
||||
"500px",
|
||||
"1000px",
|
||||
"2000px",
|
||||
"3000px",
|
||||
"4000px",
|
||||
"6000px",
|
||||
"8000px",
|
||||
)
|
||||
|
||||
for f in files:
|
||||
out = check_output(["python", "benchmark.py", f])
|
||||
print(out.decode(), end="")
|
||||
|
||||
print()
|
||||
|
||||
for f in files:
|
||||
out = check_output(["./bm", f, "--benchmark_format=csv"], stderr=DEVNULL)
|
||||
|
||||
for line in out.decode().splitlines(keepends=False):
|
||||
if line.startswith("\"BM_"):
|
||||
m, _, t, *_ = line.split(",")
|
||||
if "phash" in m:
|
||||
method = "phash"
|
||||
if "dhash" in m:
|
||||
method = "dhash"
|
||||
if "ahash" in m:
|
||||
method = "ahash"
|
||||
if "whash" in m:
|
||||
method = "whash"
|
||||
print("%s_%s,%s" % (f, method, t))
|
||||