Skip to content

Commit 7a4bdf7

Browse files
committed
Replaced space indentation with tabs in Lua scripts to lower uncompressed file size.
1 parent 63d85e5 commit 7a4bdf7

File tree

2 files changed

+106
-106
lines changed

2 files changed

+106
-106
lines changed

bench.lua

Lines changed: 101 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,162 +1,162 @@
11
#!/usr/bin/env lua
22

33
function SystemFamily()
4-
local env = os.getenv("COMSPEC")
5-
6-
if env then
7-
env = os.getenv("OS")
8-
if env then
9-
return "NT"
10-
else
11-
return "DOS"
12-
end
13-
else
14-
env = os.getenv("SHELL")
15-
if env then
16-
return "UNIX"
17-
else
18-
return "Unknown"
19-
end
20-
end
4+
local env = os.getenv("COMSPEC")
5+
6+
if env then
7+
env = os.getenv("OS")
8+
if env then
9+
return "NT"
10+
else
11+
return "DOS"
12+
end
13+
else
14+
env = os.getenv("SHELL")
15+
if env then
16+
return "UNIX"
17+
else
18+
return "Unknown"
19+
end
20+
end
2121
end
2222

2323
local function benchmark_pi()
24-
local iterations = 100000
25-
local pi = 3
26-
local sign = 1
24+
local iterations = 100000
25+
local pi = 3
26+
local sign = 1
2727

28-
io.write("Benchmarking Pi (" .. iterations .. " iterations)...\t")
28+
io.write("Benchmarking Pi (" .. iterations .. " iterations)...\t")
2929

30-
local start_time = os.clock()
30+
local start_time = os.clock()
3131

32-
-- Calculate using Nilakantha series
33-
for i = 2, iterations * 2, 2 do
34-
pi = pi + sign * (4 / (i * (i + 1) * (i + 2)))
35-
sign = -sign -- Alternate the sign for each term
36-
end
32+
-- Calculate using Nilakantha series
33+
for i = 2, iterations * 2, 2 do
34+
pi = pi + sign * (4 / (i * (i + 1) * (i + 2)))
35+
sign = -sign -- Alternate the sign for each term
36+
end
3737

38-
local end_time = os.clock()
38+
local end_time = os.clock()
3939

40-
io.write(string.format("%.6f", end_time - start_time) .. " seconds\n")
40+
io.write(string.format("%.6f", end_time - start_time) .. " seconds\n")
4141
end
4242

4343
local function benchmark_gcd()
4444

45-
-- Function to compute the greatest common divisor
46-
local function gcd(a, b)
47-
while b ~= 0 do
48-
a, b = b, a % b
49-
end
50-
return a
51-
end
45+
-- Function to compute the greatest common divisor
46+
local function gcd(a, b)
47+
while b ~= 0 do
48+
a, b = b, a % b
49+
end
50+
return a
51+
end
5252

53-
local iterations = 100000
54-
local result = 0
53+
local iterations = 100000
54+
local result = 0
5555

56-
io.write("Benchmarking GCD (" .. iterations .. " iterations)...\t")
56+
io.write("Benchmarking GCD (" .. iterations .. " iterations)...\t")
5757

58-
local start_time = os.clock()
58+
local start_time = os.clock()
5959

60-
for i = 1, iterations do
61-
local x = i
62-
local y = iterations - i + 1
63-
result = gcd(x, y)
64-
end
60+
for i = 1, iterations do
61+
local x = i
62+
local y = iterations - i + 1
63+
result = gcd(x, y)
64+
end
6565

66-
local end_time = os.clock()
66+
local end_time = os.clock()
6767

68-
io.write(string.format("%.6f", end_time - start_time) .. " seconds\n")
68+
io.write(string.format("%.6f", end_time - start_time) .. " seconds\n")
6969
end
7070

7171
local function benchmark_mul()
72-
local iterations = 100000
72+
local iterations = 100000
7373

74-
io.write("Benchmarking Mul (" .. iterations .. " iterations)...\t")
74+
io.write("Benchmarking Mul (" .. iterations .. " iterations)...\t")
7575

76-
local start_time = os.clock()
77-
local result = 1
78-
for i = 1, iterations do
79-
result = (result * i) % 1000000007 -- Keep the result small to avoid overflow
80-
end
76+
local start_time = os.clock()
77+
local result = 1
78+
for i = 1, iterations do
79+
result = (result * i) % 1000000007 -- Keep the result small to avoid overflow
80+
end
8181

82-
local end_time = os.clock()
82+
local end_time = os.clock()
8383

84-
io.write(string.format("%.6f", end_time - start_time) .. " seconds\n")
84+
io.write(string.format("%.6f", end_time - start_time) .. " seconds\n")
8585
end
8686

8787
local function benchmark_div()
88-
local iterations = 100000
88+
local iterations = 100000
8989

90-
io.write("Benchmarking Div (" .. iterations .. " iterations)...\t")
91-
iterations = iterations + 1
90+
io.write("Benchmarking Div (" .. iterations .. " iterations)...\t")
91+
iterations = iterations + 1
9292

93-
local start_time = os.clock()
94-
local result = 1
95-
for i = 2, iterations do
96-
result = result / i -- Add 10 to avoid divide-by-zero
97-
end
93+
local start_time = os.clock()
94+
local result = 1
95+
for i = 2, iterations do
96+
result = result / i
97+
end
9898

99-
local end_time = os.clock()
99+
local end_time = os.clock()
100100

101-
io.write(string.format("%.6f", end_time - start_time) .. " seconds\n")
101+
io.write(string.format("%.6f", end_time - start_time) .. " seconds\n")
102102
end
103103

104104
local function benchmark_add()
105-
local iterations = 100000
105+
local iterations = 100000
106106

107-
io.write("Benchmarking Add (" .. iterations .. " iterations)...\t")
107+
io.write("Benchmarking Add (" .. iterations .. " iterations)...\t")
108108

109-
local start_time = os.clock()
110-
local result = 1
111-
for i = 1, iterations do
112-
result = result + i
113-
end
109+
local start_time = os.clock()
110+
local result = 1
111+
for i = 1, iterations do
112+
result = result + i
113+
end
114114

115-
local end_time = os.clock()
115+
local end_time = os.clock()
116116

117-
io.write(string.format("%.6f", end_time - start_time) .. " seconds\n")
117+
io.write(string.format("%.6f", end_time - start_time) .. " seconds\n")
118118
end
119119

120120
local function benchmark_sub()
121-
local iterations = 100000
121+
local iterations = 100000
122122

123-
io.write("Benchmarking Sub (" .. iterations .. " iterations)...\t")
123+
io.write("Benchmarking Sub (" .. iterations .. " iterations)...\t")
124124

125-
local start_time = os.clock()
126-
local result = 1
127-
for i = iterations, 1, -1 do
128-
result = result - i
129-
end
125+
local start_time = os.clock()
126+
local result = 1
127+
for i = iterations, 1, -1 do
128+
result = result - i
129+
end
130130

131-
local end_time = os.clock()
131+
local end_time = os.clock()
132132

133-
io.write(string.format("%.6f", end_time - start_time) .. " seconds\n")
133+
io.write(string.format("%.6f", end_time - start_time) .. " seconds\n")
134134
end
135135

136136
local function benchmark_array()
137-
local elements = 1000 -- Total number of array elements (adjust for intensity)
137+
local elements = 1000
138138

139-
io.write("Benchmarking Array (" .. elements .. " iterations)...\t")
139+
io.write("Benchmarking Array (" .. elements .. " iterations)...\t")
140140

141-
local start_time = os.clock()
141+
local start_time = os.clock()
142142

143-
local array = {}
144-
for i = 1, elements do
145-
array[i] = i % 10 -- Arbitrary initialization
146-
end
143+
local array = {}
144+
for i = 1, elements do
145+
array[i] = i % 10
146+
end
147147

148-
for i = 1, elements do
149-
array[i] = array[i] * 2 -- Double every element
150-
end
148+
for i = 1, elements do
149+
array[i] = array[i] * 2
150+
end
151151

152-
local sum = 0
153-
for i = 1, elements do
154-
sum = sum + array[i]
155-
end
152+
local sum = 0
153+
for i = 1, elements do
154+
sum = sum + array[i]
155+
end
156156

157-
local end_time = os.clock()
157+
local end_time = os.clock()
158158

159-
io.write(string.format("%.6f", end_time - start_time) .. " seconds\n")
159+
io.write(string.format("%.6f", end_time - start_time) .. " seconds\n")
160160
end
161161

162162
-- Some information
@@ -185,4 +185,4 @@ end_time = os.clock()
185185

186186
print()
187187
print("Total memory usage (KB):", collectgarbage("count"))
188-
print("Total benchmark time: ", string.format("%.6f", end_time - start_time))
188+
print("Total benchmark time: ", string.format("%.6f", end_time - start_time))

readme.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88

99
hour = tonumber(os.date('%H')) -- Get the hour of day on the computers clock
1010
if hour < 4 or hour > 20 then -- Convert hour into fuzzy time of day
11-
timeOfDay = 'night'
11+
timeOfDay = 'night'
1212
elseif hour < 9 then
13-
timeOfDay = 'morning'
13+
timeOfDay = 'morning'
1414
elseif hour > 16 then
15-
timeOfDay = 'evening'
15+
timeOfDay = 'evening'
1616
else
17-
timeOfDay = 'day'
17+
timeOfDay = 'day'
1818
end
1919

2020
print('Good ' .. timeOfDay .. ' from ' .. _VERSION .. '.') -- Print a greeting
2121
io.read() -- Wait for Enter to be pressed
2222
print('Have a good ' .. timeOfDay .. '.') -- This message will
23-
os.exit() -- Exit script. Will also exit a interactive shell
23+
os.exit() -- Exit script. Will also exit a interactive shell

0 commit comments

Comments
 (0)