diff --git a/.github/workflows/run.yaml b/.github/workflows/run.yaml new file mode 100644 index 0000000..9f288bd --- /dev/null +++ b/.github/workflows/run.yaml @@ -0,0 +1,87 @@ +name: Run Benchmarks + +on: + push: + branches: + - main + +jobs: + build: + runs-on: macOS-14-arm64 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Update Homebrew registry + uses: brew update + + - name: Set up Dart + run: | + brew tap dart-lang/dart + brew install dart + + - name: Set up Dotnet + run: brew install dotnet + + - name: Set up Elixir + run: brew install elixir + + - name: Set up Elvish + run: brew install elvish + + - name: Set up Fish + run: brew install fish + + - name: Set up Godot for GDScript + run: brew install godot + + - name: Set up Guile + run: brew install guile + + - name: Set up Julia + run: brew install julia + + - name: Set up Lua + run: brew install lua + + - name: Set up Luajit + run: brew install luajit + + - name: Set up Ngs + run: brew install ngs + + # - name: Set up Nim + # run: brew install nim + + - name: Set up Nushell + run: brew install nushell + + - name: Set up Osh + run: brew install osh + + - name: Set up Php + run: brew install php + + - name: Set up Python + uses: actions/setup-python@v5 + + - name: Set up Racket + run: brew install minimal-racket + + - name: Set up Scala-cli + run: brew install scala-cli + + - name: Set up V + run: brew install v + + - name: Install Make + run: | + sudo apt update + sudo apt install make + + - name: Run main benchmark + run: make run + + - name: Run shebang-scripts benchmark + run: make run-shebangs diff --git a/makefile b/makefile index 4a09672..14019f8 100644 --- a/makefile +++ b/makefile @@ -1,3 +1,8 @@ +.PHONY: help +help: makefile + @tail -n +4 makefile | grep ".PHONY" + + .PHONY: run run: @hyperfine --version @@ -25,3 +30,37 @@ run: 'nickel export bin-calculation.ncl' \ 'typst query --field=text --one bin-calculation.typ "
"' + +.PHONY: run-shebangs +run-shebangs: + cd shebang-scripts/today && \ + hyperfine \ + --shell none \ + --warmup 10 \ + './bash' \ + './bun' \ + './dart' \ + './dash' \ + './elixir' \ + './elvish' \ + './fish' \ + './fsharp.fsx' \ + './guile' \ + './haskell' \ + './julia' \ + './ksh' \ + './lua' \ + './luajit' \ + './nushell' \ + './ocaml' \ + './osh' \ + './perl' \ + './php' \ + './python' \ + './racket' \ + './roc.roc' \ + './ruby' \ + './scala' \ + './swift' \ + './v.vsh' + diff --git a/shebang-scripts/today/bash b/shebang-scripts/today/bash new file mode 100755 index 0000000..e8290f3 --- /dev/null +++ b/shebang-scripts/today/bash @@ -0,0 +1,3 @@ +#! /bin/bash + +date -u "+%Y-%m-%d" diff --git a/shebang-scripts/today/bun b/shebang-scripts/today/bun new file mode 100755 index 0000000..4df816b --- /dev/null +++ b/shebang-scripts/today/bun @@ -0,0 +1,3 @@ +#! /Users/adrian/.bun/bin/bun + +console.log(new Date().toISOString().slice(0, 10)) diff --git a/shebang-scripts/today/dart b/shebang-scripts/today/dart new file mode 100755 index 0000000..81082a9 --- /dev/null +++ b/shebang-scripts/today/dart @@ -0,0 +1,9 @@ +#! /opt/homebrew/bin/dart + +void main() { + DateTime now = DateTime.now(); + String formattedDate = + '${now.year}-${now.month.toString().padLeft(2,'0')}-${ + now.day.toString().padLeft(2,'0')}'; + print(formattedDate); +} diff --git a/shebang-scripts/today/dash b/shebang-scripts/today/dash new file mode 100755 index 0000000..2aa79d8 --- /dev/null +++ b/shebang-scripts/today/dash @@ -0,0 +1,3 @@ +#! /bin/dash + +date -u "+%Y-%m-%d" diff --git a/shebang-scripts/today/elixir b/shebang-scripts/today/elixir new file mode 100755 index 0000000..5c636d6 --- /dev/null +++ b/shebang-scripts/today/elixir @@ -0,0 +1,6 @@ +#! /usr/bin/env elixir + +# TODO: Directly calling /opt/homebrew/bin/elixir does not work + +date = Date.utc_today() +IO.puts(date) diff --git a/shebang-scripts/today/elvish b/shebang-scripts/today/elvish new file mode 100755 index 0000000..1cc68d2 --- /dev/null +++ b/shebang-scripts/today/elvish @@ -0,0 +1,3 @@ +#! /opt/homebrew/bin/elvish + +date -u "+%Y-%m-%d" diff --git a/shebang-scripts/today/fish b/shebang-scripts/today/fish new file mode 100755 index 0000000..3b71fd1 --- /dev/null +++ b/shebang-scripts/today/fish @@ -0,0 +1,3 @@ +#! /opt/homebrew/bin/fish + +date -u "+%Y-%m-%d" diff --git a/shebang-scripts/today/fsharp.fsx b/shebang-scripts/today/fsharp.fsx new file mode 100755 index 0000000..128f12e --- /dev/null +++ b/shebang-scripts/today/fsharp.fsx @@ -0,0 +1,7 @@ +#! /usr/bin/env -S dotnet fsi + +// TODO: Directly calling /opt/homebrew/bin/dotnet does not work + +open System + +printfn "%s" (DateTime.Now.Date.ToString("yyyy-MM-dd")) diff --git a/shebang-scripts/today/gdscript.gd b/shebang-scripts/today/gdscript.gd new file mode 100755 index 0000000..bf0295f --- /dev/null +++ b/shebang-scripts/today/gdscript.gd @@ -0,0 +1,7 @@ +#!/usr/bin/env -S godot -s + +extends SceneTree + +func _init(): + print(Time.get_date_string_from_system()) + quit() diff --git a/shebang-scripts/today/guile b/shebang-scripts/today/guile new file mode 100755 index 0000000..5a5a1c2 --- /dev/null +++ b/shebang-scripts/today/guile @@ -0,0 +1,7 @@ +#! /opt/homebrew/bin/guile +!# + +(use-modules (srfi srfi-19)) + +(display (date->string (current-date) "~Y-~m-~e")) +(newline) diff --git a/shebang-scripts/today/haskell b/shebang-scripts/today/haskell new file mode 100755 index 0000000..fda9e58 --- /dev/null +++ b/shebang-scripts/today/haskell @@ -0,0 +1,9 @@ +#! /Users/adrian/.ghcup/bin/stack +-- stack script --package time --snapshot lts-22.22 + +import Data.Time + +main :: IO () +main = do + today <- getCurrentTime + print $ utctDay today diff --git a/shebang-scripts/today/julia b/shebang-scripts/today/julia new file mode 100755 index 0000000..6d0e5bc --- /dev/null +++ b/shebang-scripts/today/julia @@ -0,0 +1,5 @@ +#! /opt/homebrew/bin/julia + +using Dates + +println(today()) diff --git a/shebang-scripts/today/ksh b/shebang-scripts/today/ksh new file mode 100755 index 0000000..2441e2c --- /dev/null +++ b/shebang-scripts/today/ksh @@ -0,0 +1,3 @@ +#! /bin/ksh + +date -u "+%Y-%m-%d" diff --git a/shebang-scripts/today/lua b/shebang-scripts/today/lua new file mode 100755 index 0000000..8846133 --- /dev/null +++ b/shebang-scripts/today/lua @@ -0,0 +1,3 @@ +#! /opt/homebrew/bin/lua + +print(os.date("%Y-%m-%dT%H:%M:%S")) diff --git a/shebang-scripts/today/luajit b/shebang-scripts/today/luajit new file mode 100755 index 0000000..88381ab --- /dev/null +++ b/shebang-scripts/today/luajit @@ -0,0 +1,3 @@ +#! /opt/homebrew/bin/luajit + +print(os.date("%Y-%m-%dT%H:%M:%S")) diff --git a/shebang-scripts/today/ngs b/shebang-scripts/today/ngs new file mode 100755 index 0000000..80199cf --- /dev/null +++ b/shebang-scripts/today/ngs @@ -0,0 +1,3 @@ +#! /opt/homebrew/bin/ngs + +date -u "+%Y-%m-%d" diff --git a/shebang-scripts/today/nim.nims b/shebang-scripts/today/nim.nims new file mode 100755 index 0000000..c8bb8b8 --- /dev/null +++ b/shebang-scripts/today/nim.nims @@ -0,0 +1,9 @@ +#! /opt/homebrew/bin/nim e --hints:off + +mode = ScriptMode.Silent + +# TODO: Importing std/times is not working in a NimScript +# import std/times +# echo now().format("yyyy-MM-dd") + +echo "Hello World!" diff --git a/shebang-scripts/today/nushell b/shebang-scripts/today/nushell new file mode 100755 index 0000000..04bd25d --- /dev/null +++ b/shebang-scripts/today/nushell @@ -0,0 +1,3 @@ +#! /opt/homebrew/bin/nu + +date now | format date "%Y-%m-%d" diff --git a/shebang-scripts/today/ocaml b/shebang-scripts/today/ocaml new file mode 100755 index 0000000..e51acd1 --- /dev/null +++ b/shebang-scripts/today/ocaml @@ -0,0 +1,10 @@ +#! /usr/bin/env ocaml -I +unix + +#load "unix.cma";; + +let today = Unix.localtime (Unix.time ());; +let day = today.Unix.tm_mday;; +let month = today.Unix.tm_mon + 1;; +let year = today.Unix.tm_year + 1900;; + +Printf.printf "%04d-%02d-%02d\n" year month day;; diff --git a/shebang-scripts/today/osh b/shebang-scripts/today/osh new file mode 100755 index 0000000..a7b7771 --- /dev/null +++ b/shebang-scripts/today/osh @@ -0,0 +1,3 @@ +#! /opt/homebrew/bin/osh + +date -u "+%Y-%m-%d" diff --git a/shebang-scripts/today/perl b/shebang-scripts/today/perl new file mode 100755 index 0000000..84824aa --- /dev/null +++ b/shebang-scripts/today/perl @@ -0,0 +1,6 @@ +#! /usr/bin/perl + +use DateTime; + +my $dt = DateTime->now; +print $dt->ymd; diff --git a/shebang-scripts/today/php b/shebang-scripts/today/php new file mode 100755 index 0000000..fcacbb0 --- /dev/null +++ b/shebang-scripts/today/php @@ -0,0 +1,3 @@ +#! /opt/homebrew/bin/php +string n)) + (number->string n))) + +(define (get-current-date-iso) + (let* ((current-date (seconds->date (current-seconds))) + (year (date-year current-date)) + (month (date-month current-date)) + (day (date-day current-date))) + (format "~a-~a-~a" year (pad-zero month) (pad-zero day)))) + +(displayln (get-current-date-iso)) diff --git a/shebang-scripts/today/roc b/shebang-scripts/today/roc new file mode 100755 index 0000000..d2c1d96 Binary files /dev/null and b/shebang-scripts/today/roc differ diff --git a/shebang-scripts/today/roc.roc b/shebang-scripts/today/roc.roc new file mode 100755 index 0000000..c6a6847 --- /dev/null +++ b/shebang-scripts/today/roc.roc @@ -0,0 +1,16 @@ +#! /usr/bin/env roc + +app "hello-world" + packages { + pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" +} + imports [pf.Stdout, pf.Task.{ Task }, pf.Utc] + provides [main] to pf + + +main : Task {} _ +main = + now = Utc.now! + # TODO: Use https://github.com/imclerran/roc-isodate to format the date + nowStr = now |> Utc.toMillisSinceEpoch |> Num.toStr + Stdout.line! nowStr diff --git a/shebang-scripts/today/ruby b/shebang-scripts/today/ruby new file mode 100755 index 0000000..30d1f96 --- /dev/null +++ b/shebang-scripts/today/ruby @@ -0,0 +1,5 @@ +#! /usr/bin/ruby + +require 'date' + +puts DateTime.now.to_date.to_s diff --git a/shebang-scripts/today/scala b/shebang-scripts/today/scala new file mode 100755 index 0000000..f973020 --- /dev/null +++ b/shebang-scripts/today/scala @@ -0,0 +1,3 @@ +#! /opt/homebrew/bin/scala-cli shebang -S 3 + +println(java.time.LocalDate.now) diff --git a/shebang-scripts/today/swift b/shebang-scripts/today/swift new file mode 100755 index 0000000..6970d03 --- /dev/null +++ b/shebang-scripts/today/swift @@ -0,0 +1,9 @@ +#! /usr/bin/swift + +import Foundation + +let formatter = DateFormatter() +formatter.dateFormat = "yyyy-MM-dd" +let today = formatter.string(from: Date()) + +print(today) diff --git a/shebang-scripts/today/v b/shebang-scripts/today/v new file mode 100755 index 0000000..d9763e4 Binary files /dev/null and b/shebang-scripts/today/v differ diff --git a/shebang-scripts/today/v.vsh b/shebang-scripts/today/v.vsh new file mode 100755 index 0000000..bc7ee3c --- /dev/null +++ b/shebang-scripts/today/v.vsh @@ -0,0 +1,5 @@ +#! /opt/homebrew/bin/v + +import time + +println(time.now().ymmdd()) diff --git a/shebang-scripts/today/vala.vala b/shebang-scripts/today/vala.vala new file mode 100755 index 0000000..d945519 --- /dev/null +++ b/shebang-scripts/today/vala.vala @@ -0,0 +1,6 @@ +#! /opt/homebrew/bin/vala + +void main() { + // TODO: Somehow does not print the message + print("File does not exist.\n"); +}