Skip to content

Commit 5e76c86

Browse files
committed
Add benchmark for float addition
Introduce a new benchmarking function to measure float addition performance. This complements existing benchmarks and helps evaluate arithmetic operations with floating-point numbers. It is especially useful to compare CPUs with and without a FPU.
1 parent 988cd86 commit 5e76c86

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

bench.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,17 @@ local function benchmark_add()
100100
BenchmarkEnd(bm)
101101
end
102102

103+
local function benchmark_flt()
104+
local r, it = 1.0, 100000
105+
local bm = BenchmarkStart("Float Addition", it)
106+
107+
for _ = 1, it do
108+
r = r + 0.01
109+
end
110+
111+
BenchmarkEnd(bm)
112+
end
113+
103114
local function benchmark_sub()
104115
local r, it = 1, 100000
105116
local bm = BenchmarkStart("Subtraction", it)
@@ -145,6 +156,7 @@ print("Benchmark", "Iterations", "Time (min:sec.ms)")
145156
bm = os.clock()
146157

147158
benchmark_add()
159+
benchmark_flt()
148160
benchmark_sub()
149161
benchmark_mul()
150162
benchmark_div()

0 commit comments

Comments
 (0)