Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ rm v/code
rm emojicode/code emojicode/code.o
rm -f chez/code.so
rm -rf clojure/classes clojure/.cpcache
rm cobol/main
rm cobol/main
rm -f cython/code.c cython/code
5 changes: 3 additions & 2 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ emojicodec emojicode/code.emojic
echo '(compile-program "chez/code.ss")' | chez --optimize-level 3 -q
(cd clojure && mkdir -p classes && clojure -Sdeps '{:paths ["."]}' -M -e "(compile 'code)")
cobc -I /opt/homebrew/include/ -O -O2 -O3 -Os -x -o cobol/main cobol/main.cbl
lake build --dir lean4
lake build --dir lean4
#dotnet publish fsharp -o fsharp/code-aot /p:PublishAot=true /p:OptimizationPreference=Speed
# haxe --class-path haxe -main Code --jvm haxe/code.jar # was getting errors running `haxelib install hxjava`
#dotnet publish csharp -o csharp/code-aot /p:PublishAot=true /p:OptimizationPreference=Speed
#gnatmake -O3 -gnat2022 -gnatp -flto ada/code.adb -D ada -o ada/code
#gnatmake -O3 -gnat2022 -gnatp -flto ada/code.adb -D ada -o ada/code
cd cython && pip install cython && cython code.pyx --embed && clang $(python-config --includes) $(python-config --libs) -lpython3.13 -O3 code.c -o code
19 changes: 19 additions & 0 deletions loops/cython/code.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import sys
import random


def main():
cdef int u, r, i, j
cdef int a[10000]

u = int(sys.argv[1]) # Get an input number from the command line
r = random.randint(0, 10000) # Get a random number 0 <= r < 10k
a = [0] * 10000 # Array of 10k elements initialized to 0
for i in range(10000): # 10k outer loop iterations
for j in range(100000): # 100k inner loop iterations, per outer loop iteration
a[i] += j % u # Simple sum
a[i] += r # Add a random value to each element in array
print(a[r]) # Print out a single element from the array


main()
3 changes: 2 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ run "Babashka" "bb" "bb/code.clj"
#run "Haxe JVM" "java -jar haxe/code.jar" # was getting errors running `haxelib install hxjava`
#run "Ada" "./ada/code"
#run "D" "./d/code" # Seems to not have an arm / M1 version
#run "Java GraalVM" "./jvm.code"
#run "Java GraalVM" "./jvm.code"
run "Cython" "./cython/code 40"