Skip to content

Commit

Permalink
Merge pull request #46 from botantony/lua
Browse files Browse the repository at this point in the history
Add Lua
  • Loading branch information
bddicken authored Nov 29, 2024
2 parents 43fbc11 + c2ae46d commit d0ae86b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ rm jvm/code.class
rm -r rust/target
rm -rf kotlin/code.jar
rm dart/code
rm lua/code
rm -f swift/code
3 changes: 2 additions & 1 deletion compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ RUSTFLAGS="-Zlocation-detail=none" cargo +nightly build --manifest-path rust/Car
kotlinc -include-runtime kotlin/code.kt -d kotlin/code.jar
#kotlinc-native -include-runtime kotlin/code.kt -d kotlin/code
dart compile exe dart/code.dart -o dart/code --target-os=macos
swiftc -O -parse-as-library -Xcc -funroll-loops -Xcc -march=native -Xcc -ftree-vectorize -Xcc -ffast-math swift/code.swift -o swift/code
luajit -b lua/code.lua lua/code
swiftc -O -parse-as-library -Xcc -funroll-loops -Xcc -march=native -Xcc -ftree-vectorize -Xcc -ffast-math swift/code.swift -o swift/code
16 changes: 16 additions & 0 deletions fibonacci/lua/code.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
local function fibbonacci(n)
if n == 0 then
return 0
end
if n == 1 then
return 1
end
return fibbonacci(n - 1) + fibbonacci(n - 2)
end

local u = arg[1]
local r = 0
for i = 1, u - 1 do
r = r + fibbonacci(i)
end
print(r)
13 changes: 13 additions & 0 deletions loops/lua/code.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
math.randomseed(os.time())
local u = arg[1]
local r = math.random(0, 10000)
local a = {}

for i = 0, 10000 - 1 do
for j = 0, 100000 - 1 do
a[i] = (a[i] or 0) + j % u
end
a[i] = a[i] + r
end

print(a[r])
2 changes: 2 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ run "Java" "java jvm.code 40"
run "PHP" "php ./php/code.php 40"
run "R" "Rscript ./r/code.R 40"
run "Dart" "./dart/code 40"
run "LuaJIT" "luajit ./lua/code 40"
run "Lua" "lua ./lua/code.lua 40"
run "Swift" "./swift/code 40"
run "Julia" "julia ./julia/code.jl 40"
run "Ruby" "ruby ./ruby/code.rb 40"

0 comments on commit d0ae86b

Please sign in to comment.