Skip to content

Commit 2ad024c

Browse files
committed
Convert indentation in BENCH.LUA back to tabs.
1 parent 81666f2 commit 2ad024c

File tree

1 file changed

+70
-70
lines changed

1 file changed

+70
-70
lines changed

core/BENCH.LUA

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -3,124 +3,124 @@
33
---Get the operating system the script is running on
44
---@return string A string that will read: DOS, NT, UNIX or Unknown
55
function OS()
6-
if os.getenv("COMSPEC") then
7-
return os.getenv("OS") and "NT" or "DOS"
8-
else
9-
return os.getenv("SHELL") and "UNIX" or "Unknown"
10-
end
6+
if os.getenv("COMSPEC") then
7+
return os.getenv("OS") and "NT" or "DOS"
8+
else
9+
return os.getenv("SHELL") and "UNIX" or "Unknown"
10+
end
1111
end
1212

1313
---Benchmark start, prints the benchmark name and records the current time
1414
---@param name string The name of the benchmark
1515
---@param it number The number of times the benchmark will loop
1616
---@return number The current clock time
1717
function BS(name, it)
18-
local t = #tostring(it) > 10 and string.format("%10e", it):gsub("%..-e", "e") or it
19-
io.write(string.format("%-9s", name) .. "\t" .. string.format("%10s", t) .. "\t")
20-
io.flush()
21-
return os.clock()
18+
local t = #tostring(it) > 10 and string.format("%10e", it):gsub("%..-e", "e") or it
19+
io.write(string.format("%-9s", name) .. "\t" .. string.format("%10s", t) .. "\t")
20+
io.flush()
21+
return os.clock()
2222
end
2323

2424
---Benchmark end, prints the benchmarks duration
2525
---@param st number The start time returned by BS
2626
function BE(st)
27-
local t = os.clock() - st
28-
local m, s = math.floor(t / 60), t % 60
29-
io.write(string.format("%7d:%09.6f\n", m, s))
27+
local t = os.clock() - st
28+
local m, s = math.floor(t / 60), t % 60
29+
io.write(string.format("%7d:%09.6f\n", m, s))
3030
end
3131

3232
---A benchmark for calculating Pi using the Nilkantha's series
3333
local function b_pi()
34-
local it, pi, si = S, 3, 1
35-
local b = BS("Nilakantha Pi", it)
36-
for i = 2, it * 2, 2 do
37-
pi = pi + si * (4 / (i * (i + 1) * (i + 2)))
38-
si = -si
39-
end
40-
BE(b)
34+
local it, pi, si = S, 3, 1
35+
local b = BS("Nilakantha Pi", it)
36+
for i = 2, it * 2, 2 do
37+
pi = pi + si * (4 / (i * (i + 1) * (i + 2)))
38+
si = -si
39+
end
40+
BE(b)
4141
end
4242

4343
---A benchmark for calculating a common divisor
4444
local function b_gcd()
45-
local function gcd(a, b)
46-
while b ~= 0 do
47-
a, b = b, a % b
48-
end
49-
return a
50-
end
51-
local r, b = 0, BS("Common Divisor", S)
52-
for i = 1, S do
53-
local x, y = i, S - i + 1
54-
r = gcd(x, y)
55-
end
56-
BE(b)
45+
local function gcd(a, b)
46+
while b ~= 0 do
47+
a, b = b, a % b
48+
end
49+
return a
50+
end
51+
local r, b = 0, BS("Common Divisor", S)
52+
for i = 1, S do
53+
local x, y = i, S - i + 1
54+
r = gcd(x, y)
55+
end
56+
BE(b)
5757
end
5858

5959
---A benchmark for calculating multiplication performance
6060
local function b_mul()
61-
local r, b = 1, BS("Multiplication", B)
62-
for _ = 1, B do
63-
r = (r * 1.000000001)
64-
end
65-
BE(b)
61+
local r, b = 1, BS("Multiplication", B)
62+
for _ = 1, B do
63+
r = (r * 1.000000001)
64+
end
65+
BE(b)
6666
end
6767

6868
---A benchmark for calculating division performance
6969
local function b_div()
70-
local m, r = B, 1
71-
local b = BS("Division", m)
72-
m = m + 1
73-
for i = 2, m do
74-
r = r / i
75-
end
76-
BE(b)
70+
local m, r = B, 1
71+
local b = BS("Division", m)
72+
m = m + 1
73+
for i = 2, m do
74+
r = r / i
75+
end
76+
BE(b)
7777
end
7878

7979
---A benchmark for calculating addition performance
8080
local function b_add()
81-
local r, b = 1, BS("Addition", B)
82-
for i = 1, B do
83-
r = r + i
84-
end
85-
BE(b)
81+
local r, b = 1, BS("Addition", B)
82+
for i = 1, B do
83+
r = r + i
84+
end
85+
BE(b)
8686
end
8787

8888
---A benchmark for calculating floating point addition performance
8989
local function b_flt()
90-
local r, b = 1.0, BS("Float Addition", B)
91-
for _ = 1, B do
92-
r = r + 0.01
93-
end
94-
BE(b)
90+
local r, b = 1.0, BS("Float Addition", B)
91+
for _ = 1, B do
92+
r = r + 0.01
93+
end
94+
BE(b)
9595
end
9696

9797
---A benchmark for calculating subtraction performance
9898
local function b_sub()
99-
local r, b = 1, BS("Subtraction", B)
100-
for i = B, 1, -1 do
101-
r = r - i
102-
end
103-
BE(b)
99+
local r, b = 1, BS("Subtraction", B)
100+
for i = B, 1, -1 do
101+
r = r - i
102+
end
103+
BE(b)
104104
end
105105

106106
---A benchmark for calculating array iteration performance
107107
local function b_arr()
108-
local b, a, s = BS("Array Loop", S), {}, 0
109-
for i = 1, S do
110-
a[i] = i % 10
111-
end
112-
for i = 1, S do
113-
a[i] = a[i] * 2
114-
end
115-
for i = 1, S do
116-
s = s + a[i]
117-
end
118-
BE(b)
108+
local b, a, s = BS("Array Loop", S), {}, 0
109+
for i = 1, S do
110+
a[i] = i % 10
111+
end
112+
for i = 1, S do
113+
a[i] = a[i] * 2
114+
end
115+
for i = 1, S do
116+
s = s + a[i]
117+
end
118+
BE(b)
119119
end
120120

121121
---Print a horizontal line on the screen
122122
local function L()
123-
print(string.rep('_', 49))
123+
print(string.rep('_', 49))
124124
end
125125

126126
--Print basic system and Lua information

0 commit comments

Comments
 (0)