1- if not LIB then print (" Please run bench.lua from the same working directory instead" ) return end
2-
3- local function benchmark_md5sum ()
4- local it , s = 2 , pcall (require , " MD5SUM" )
5- local bm = BS (" Checksum MD5" , it )
6- local file = io.open (arg [0 ], " rb" )
7-
8- if not s or not file then
9- if file then file :close () end
10- print (string.format (" %17s" , " Skipped" ))
11- return
12- end
13-
14- for _ = 1 , it do
15- md5_file (file )
16- file :seek (" set" , 0 )
17- end
18- file :close ()
19- BE (bm )
20- end
21-
22- local function benchmark_sha256 ()
23- local it , s = 1 , pcall (require , " S256SUM" )
24- local bm = BS (" Checksum SHA256" , it )
25- local file = io.open (arg [0 ], " rb" )
26-
27- if not s or not file then
28- if file then file :close () end
29- print (string.format (" %17s" , " Skipped" ))
30- return
31- end
32-
33- for _ = 1 , it do
34- sha256_file (file )
35- file :seek (" set" , 0 )
36- end
37- file :close ()
38- BE (bm )
39- end
40-
41- benchmark_md5sum ()
42- benchmark_sha256 ()
1+ if not LIB then print (" Please run bench.lua from the same working directory instead" ) return end
2+
3+ local function benchmark_md5sum ()
4+ local it , s = 2 , pcall (require , " MD5SUM" )
5+ local bm = BS (" Checksum MD5" , it )
6+ local file = io.open (arg [0 ], " rb" )
7+
8+ if not s or not file then
9+ if file then file :close () end
10+ print (string.format (" %17s" , " Skipped" ))
11+ return
12+ end
13+
14+ for _ = 1 , it do
15+ md5_file (file )
16+ file :seek (" set" , 0 )
17+ end
18+ file :close ()
19+ BE (bm )
20+ end
21+
22+ local function benchmark_sha256 ()
23+ local it , s = 1 , pcall (require , " S256SUM" )
24+ local bm = BS (" Checksum SHA256" , it )
25+ local file = io.open (arg [0 ], " rb" )
26+
27+ if not s or not file then
28+ if file then file :close () end
29+ print (string.format (" %17s" , " Skipped" ))
30+ return
31+ end
32+
33+ for _ = 1 , it do
34+ sha256_file (file )
35+ file :seek (" set" , 0 )
36+ end
37+ file :close ()
38+ BE (bm )
39+ end
40+
41+ benchmark_md5sum ()
42+ benchmark_sha256 ()
0 commit comments