Skip to content

Commit 81666f2

Browse files
committed
Make sure BENCH.LUA always waits for user input before exiting.
1 parent 1c16693 commit 81666f2

File tree

1 file changed

+31
-32
lines changed

1 file changed

+31
-32
lines changed

core/BENCH.LUA

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -131,40 +131,39 @@ print("Maximum Int:", math.maxinteger or "Unknown")
131131

132132
--Check what benchmark to run
133133
M = tonumber(arg[1])
134-
if not M or M < 1980 then
135-
print("\nTo benchmark,run again and specify a year > 1979")
136-
os.exit()
134+
if M and M > 1979 then
135+
print("\nRunning benchmark: " .. M)
136+
137+
--Make the benchmark do more iterations of every test for each year above 1980
138+
M = (M - 1955) / 25
139+
B, S = math.floor(500 ^ M), math.floor(100 ^ M)
140+
141+
print("\nBenchmark", "Iterations", "Time (min:sec.ms)")
142+
L()
143+
--Benchmark Start
144+
b = os.clock()
145+
b_add()
146+
b_flt()
147+
b_sub()
148+
b_mul()
149+
b_div()
150+
b_pi()
151+
b_gcd()
152+
b_arr()
153+
154+
--Run extended benchmarks if available
155+
LIB = true
156+
package.path = package.path .. ";?.LUA" --In case of a case sensitive operating system
157+
pcall(require, "EXBENCH")
158+
159+
--Benchmark Finish
160+
L()
161+
io.write("Total:\t\t" .. string.format("%8.3fkB", collectgarbage("count")) .. "\t")
162+
BE(b)
163+
else
164+
print("\nTo benchmark, run again and specify a year > 1979")
137165
end
138166

139-
print("\nRunning benchmark: " .. M)
140-
141-
--Make the benchmark do more iterations of every test for each year above 1980
142-
M = (M - 1955) / 25
143-
B, S = math.floor(500 ^ M), math.floor(100 ^ M)
144-
145-
print("\nBenchmark", "Iterations", "Time (min:sec.ms)")
146-
L()
147-
--Benchmark Start
148-
b = os.clock()
149-
b_add()
150-
b_flt()
151-
b_sub()
152-
b_mul()
153-
b_div()
154-
b_pi()
155-
b_gcd()
156-
b_arr()
157-
158-
--Run extended benchmarks if available
159-
LIB = true
160-
package.path = package.path .. ";?.LUA" --In case of a case sensitive operating system
161-
pcall(require, "EXBENCH")
162-
163-
--Benchmark Finish
164-
L()
165-
io.write("Total:\t\t" .. string.format("%8.3fkB", collectgarbage("count")) .. "\t")
166-
BE(b)
167-
168167
--Wait for user input so the benchmark results can be read on operating systems that would automatically close the window
169168
print("Press Enter to Exit...")
170169
io.read()

0 commit comments

Comments
 (0)