Skip to content

Commit

Permalink
Add several more shebang script files
Browse files Browse the repository at this point in the history
  • Loading branch information
ad-si committed Jun 12, 2024
1 parent 634302d commit d7bac96
Show file tree
Hide file tree
Showing 34 changed files with 302 additions and 0 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/run.yaml
Original file line number Diff line number Diff line change
@@ -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
39 changes: 39 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.PHONY: help
help: makefile
@tail -n +4 makefile | grep ".PHONY"


.PHONY: run
run:
@hyperfine --version
Expand Down Expand Up @@ -25,3 +30,37 @@ run:
'nickel export bin-calculation.ncl' \
'typst query --field=text --one bin-calculation.typ "<main>"'


.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'

3 changes: 3 additions & 0 deletions shebang-scripts/today/bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /bin/bash

date -u "+%Y-%m-%d"
3 changes: 3 additions & 0 deletions shebang-scripts/today/bun
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /Users/adrian/.bun/bin/bun

console.log(new Date().toISOString().slice(0, 10))
9 changes: 9 additions & 0 deletions shebang-scripts/today/dart
Original file line number Diff line number Diff line change
@@ -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);
}
3 changes: 3 additions & 0 deletions shebang-scripts/today/dash
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /bin/dash

date -u "+%Y-%m-%d"
6 changes: 6 additions & 0 deletions shebang-scripts/today/elixir
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 3 additions & 0 deletions shebang-scripts/today/elvish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /opt/homebrew/bin/elvish

date -u "+%Y-%m-%d"
3 changes: 3 additions & 0 deletions shebang-scripts/today/fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /opt/homebrew/bin/fish

date -u "+%Y-%m-%d"
7 changes: 7 additions & 0 deletions shebang-scripts/today/fsharp.fsx
Original file line number Diff line number Diff line change
@@ -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"))
7 changes: 7 additions & 0 deletions shebang-scripts/today/gdscript.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env -S godot -s

extends SceneTree

func _init():
print(Time.get_date_string_from_system())
quit()
7 changes: 7 additions & 0 deletions shebang-scripts/today/guile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /opt/homebrew/bin/guile
!#

(use-modules (srfi srfi-19))

(display (date->string (current-date) "~Y-~m-~e"))
(newline)
9 changes: 9 additions & 0 deletions shebang-scripts/today/haskell
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions shebang-scripts/today/julia
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! /opt/homebrew/bin/julia

using Dates

println(today())
3 changes: 3 additions & 0 deletions shebang-scripts/today/ksh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /bin/ksh

date -u "+%Y-%m-%d"
3 changes: 3 additions & 0 deletions shebang-scripts/today/lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /opt/homebrew/bin/lua

print(os.date("%Y-%m-%dT%H:%M:%S"))
3 changes: 3 additions & 0 deletions shebang-scripts/today/luajit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /opt/homebrew/bin/luajit

print(os.date("%Y-%m-%dT%H:%M:%S"))
3 changes: 3 additions & 0 deletions shebang-scripts/today/ngs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /opt/homebrew/bin/ngs

date -u "+%Y-%m-%d"
9 changes: 9 additions & 0 deletions shebang-scripts/today/nim.nims
Original file line number Diff line number Diff line change
@@ -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!"
3 changes: 3 additions & 0 deletions shebang-scripts/today/nushell
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /opt/homebrew/bin/nu

date now | format date "%Y-%m-%d"
10 changes: 10 additions & 0 deletions shebang-scripts/today/ocaml
Original file line number Diff line number Diff line change
@@ -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;;
3 changes: 3 additions & 0 deletions shebang-scripts/today/osh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /opt/homebrew/bin/osh

date -u "+%Y-%m-%d"
6 changes: 6 additions & 0 deletions shebang-scripts/today/perl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#! /usr/bin/perl

use DateTime;

my $dt = DateTime->now;
print $dt->ymd;
3 changes: 3 additions & 0 deletions shebang-scripts/today/php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /opt/homebrew/bin/php
<?php
echo date("Y-m-d")."\n";
5 changes: 5 additions & 0 deletions shebang-scripts/today/python
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! /Users/adrian/.rye/shims/python

import datetime

print(datetime.datetime.now().isoformat()[:10])
16 changes: 16 additions & 0 deletions shebang-scripts/today/racket
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#! /opt/homebrew/bin/racket
#lang racket/base

(define (pad-zero n)
(if (< n 10)
(string-append "0" (number->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))
Binary file added shebang-scripts/today/roc
Binary file not shown.
16 changes: 16 additions & 0 deletions shebang-scripts/today/roc.roc
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions shebang-scripts/today/ruby
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! /usr/bin/ruby

require 'date'

puts DateTime.now.to_date.to_s
3 changes: 3 additions & 0 deletions shebang-scripts/today/scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /opt/homebrew/bin/scala-cli shebang -S 3

println(java.time.LocalDate.now)
9 changes: 9 additions & 0 deletions shebang-scripts/today/swift
Original file line number Diff line number Diff line change
@@ -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)
Binary file added shebang-scripts/today/v
Binary file not shown.
5 changes: 5 additions & 0 deletions shebang-scripts/today/v.vsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! /opt/homebrew/bin/v

import time

println(time.now().ymmdd())
6 changes: 6 additions & 0 deletions shebang-scripts/today/vala.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#! /opt/homebrew/bin/vala

void main() {
// TODO: Somehow does not print the message
print("File does not exist.\n");
}

0 comments on commit d7bac96

Please sign in to comment.