print-hello-world

A potpourri of programming languages

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
#!/usr/bin/bash

# Compile
gcc test.c -o testc -O2 -march=native                       # C
g++ test.cpp -o testcpp -O2 -march=native                   # C++
python -m py_compile test.py                                # Python
javac test.java                                             # Java
mcs test.cs                                                 # C#
go build -o testgo test.go                                  # Go
rustc test.rs -C opt-level=2 -C target-cpu=native -o testrs # Rust
ghc -dynamic -O test.hs -o tesths                           # Haskell

# Run benchmarks
run=('./testc'                                              # C
     './testcpp'                                            # C++
     'python test.py'                                       # Python
     'java test'                                            # Java
     'mono test.exe'                                        # C#
     'node test.js'                                         # Node
     'perl test.pl'                                         # Perl
     'ruby test.rb'                                         # Ruby
     './testgo'                                             # Go
     './testrs'                                             # Rust
     './tesths'                                             # Haskell
     'julia test.jl'                                        # Julia
     'Rscript test.r'                                       # R
     'ecl --shell test.lisp'                                # Common Lisp
     'lua test.lua'                                         # Lua
     'elixir test.exs'                                      # Elixir
)
echo ${run[@]@Q} | xargs hyperfine --export-json data.json

# Cleanup
rm testc testcpp test.class test.exe testgo testrs tesths test.o test.hi
rm __pycache__ -r