Skip to content

Commit fae1bd7

Browse files
committed
add swift
1 parent fae1f8d commit fae1bd7

File tree

6 files changed

+101
-44
lines changed

6 files changed

+101
-44
lines changed

.github/workflows/ci.yml

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,43 @@ jobs:
1414
matrix:
1515
# do the slow ones first, to make the overall build quicker
1616
build:
17-
# - 00_tcl
18-
- 01_prolog
19-
- 02_smalltalk
20-
- 03_python3
21-
- 04_julia
22-
- 05_perl
23-
- 06_cobol
24-
- 07_haskell
25-
- 08_ruby
26-
- 09_forth
27-
- 10_lua
28-
- 11_ocaml
29-
- 12_php
30-
- 13_erlang
31-
- 14_crystal
32-
- 15_scala
33-
- 16_csharp
34-
- 17_coffeescript
35-
- 18_kotlin
36-
- 19_java
37-
- 20_deno
38-
- 21_node
39-
- 22_go
40-
- 23_bun
41-
- 24_fortran
42-
- 25_rust
43-
- 26_vala
44-
- 27_cpp-clang
45-
- 28_cpp-gcc
46-
- 29_c-clang
47-
- 30_c-gcc
48-
- 31_nim
49-
- 32_pascal
50-
- 33_zig
51-
- 34_assembly
17+
# - tcl
18+
- prolog
19+
- smalltalk
20+
- python3
21+
- julia
22+
- perl
23+
- swift
24+
- cobol
25+
- ruby
26+
- haskell
27+
- forth
28+
- lua
29+
- ocaml
30+
- php
31+
- erlang
32+
- crystal
33+
- scala
34+
- csharp
35+
- coffeescript
36+
- kotlin
37+
- java
38+
- deno
39+
- node
40+
- go
41+
- bun
42+
- fortran
43+
- rust
44+
- swiftc
45+
- vala
46+
- cpp-clang
47+
- cpp-gcc
48+
- c-clang
49+
- c-gcc
50+
- nim
51+
- pascal
52+
- zig
53+
- assembly
5254
runs-on: ubuntu-latest
5355
container:
5456
image: acheronfail/count

count.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
var i = 0
2+
let target = Int(CommandLine.arguments[1])!
3+
while i < target {
4+
i = (i + 1) | 1;
5+
}
6+
7+
print("\(i)")

Dockerfile renamed to docker/Dockerfile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ RUN curl -fSL \
3838
https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh \
3939
| bash
4040
RUN cargo install ripgrep --features pcre2
41-
RUN cargo binstall --no-confirm hyperfine just timers juliaup
41+
RUN cargo binstall --no-confirm hyperfine just max_rss juliaup
4242

4343
RUN juliaup add release && juliaup config versionsdbupdateinterval 0
4444

@@ -53,13 +53,12 @@ RUN curl -fSL https://crystal-lang.org/install.sh | bash -s -- --version=1.11
5353
RUN curl -fSL https://nim-lang.org/choosenim/init.sh | sh -s -- -y
5454
ENV PATH="/root/.nimble/bin:$PATH"
5555

56-
RUN cd && curl -fSL "$(curl -fSL https://ziglang.org/download/index.json | jq -r '.[keys_unsorted[1]]["x86_64-linux"].tarball')" \
57-
> zig.tar.xz \
58-
&& mkdir -p "/root/.zig" \
59-
&& tar -xvf zig.tar.xz --strip-components=1 -C "/root/.zig" \
60-
&& rm zig.tar.xz
56+
COPY ./zig.sh ./zig.sh
57+
RUN ./zig.sh
6158
ENV PATH="/root/.zig:$PATH"
6259

63-
RUN cargo install max_rss --version 0.4.1
60+
COPY ./swift.sh ./swift.sh
61+
RUN ./swift.sh
62+
ENV PATH="/root/.swift/usr/bin:$PATH"
6463

6564
WORKDIR /var/count

docker/swift.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
# https://www.swift.org/install/linux/#installation-via-tarball
4+
5+
set -euxo pipefail
6+
cd "$HOME"
7+
8+
install_dir="$HOME/.swift"
9+
10+
tarball_url="https://download.swift.org/swift-5.9.2-release/ubuntu2204/swift-5.9.2-RELEASE/swift-5.9.2-RELEASE-ubuntu22.04.tar.gz"
11+
tarball_sig_url="${tarball_url}.sig"
12+
13+
tarball="swift.tar.gz"
14+
tarball_sig="swift.tar.gz.sig"
15+
16+
wget -q -O - https://swift.org/keys/all-keys.asc | gpg --import -
17+
18+
curl -fSL "$tarball_url" > "$tarball"
19+
curl -fSL "$tarball_sig_url" > "$tarball_sig"
20+
gpg --verify "$tarball_sig"
21+
22+
mkdir -p "$install_dir"
23+
tar -xvf "$tarball" --strip-components=1 -C "$install_dir"
24+
rm "$tarball"

docker/zig.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
set -euxo pipefail
4+
cd "$HOME"
5+
6+
install_dir="$HOME/.zig"
7+
jq_path='.[keys_unsorted[1]]["x86_64-linux"].tarball'
8+
tarball_url=$(curl -fSL https://ziglang.org/download/index.json | jq -r "$jq_path")
9+
tarball="zig.tar.xz"
10+
11+
curl -fSL "$tarball_url" > $tarball
12+
mkdir -p "$install_dir"
13+
14+
tar -xvf $tarball --strip-components=1 -C "$install_dir"
15+
rm $tarball

justfile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ docker-sh:
1818
# - mono fails to install (https://github.com/mono/mono/issues/21423)
1919
# - running anything with erlang segfaults
2020
docker-build:
21-
docker build --progress=plain --platform 'linux/amd64' -t {{tag}} .
21+
docker build --progress=plain --platform 'linux/amd64' -t {{tag}} ./docker
2222

2323
docker-pull:
2424
docker pull {{tag}}
@@ -73,12 +73,13 @@ measure what:
7373
python
7474
ruby
7575
smalltalk
76+
swift
7677
tcl
7778
)
7879

7980
args="--warmup 3"
8081
for language in "${slow_langs[@]}"; do
81-
if [[ "{{what}}" == *"$language"* ]]; then
82+
if [[ "{{what}}" == "$language" ]]; then
8283
args="--runs 1"
8384
break
8485
fi
@@ -329,3 +330,12 @@ build-vala: (_check "valac") && (_size "count")
329330
valac --version > VERSION
330331
valac ./count.vala -o count --Xcc=-O3
331332
echo './count {{i}}' > CMD
333+
334+
build-swift: (_check "swift")
335+
swift --version > VERSION
336+
echo 'swift ./count.swift {{i}}' > CMD
337+
338+
build-swiftc: (_check "swiftc") && (_size "count")
339+
swiftc --version > VERSION
340+
swiftc ./count.swift -o count -O
341+
echo './count {{i}}' > CMD

0 commit comments

Comments
 (0)