Skip to content

Add Idris2 json benchmark #504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ef3692c
Adding files for new Idris2 brainfuck array implementation, as well a…
Matthew-Mosior Dec 17, 2024
c7f986d
Adding updated Idris2 brainfuck/brainfuck-array implementations.
Matthew-Mosior Dec 17, 2024
0c3c236
Removing snoclist implementation.
Matthew-Mosior Dec 17, 2024
17b603c
Updating Idris2 paths.
Matthew-Mosior Dec 17, 2024
8e1548a
Removing old Idris2 build command.
Matthew-Mosior Dec 17, 2024
2b11a65
Updating required files.
Matthew-Mosior Dec 17, 2024
0b82db7
Fixing .gitmodules.
Matthew-Mosior Dec 17, 2024
df3fbe7
Updating Makefile.
Matthew-Mosior Dec 17, 2024
ead2c28
Fixing both Makefile and commands.mk.
Matthew-Mosior Dec 17, 2024
c4a22d3
Cleaning up Dockerfile.
Matthew-Mosior Dec 17, 2024
06cd1a8
Updating Dockerfile.
Matthew-Mosior Dec 17, 2024
c10e9ee
Reverting changes to README.md.
Matthew-Mosior Dec 17, 2024
dd1fffd
Updating Dockerfile.
Matthew-Mosior Dec 17, 2024
200eeb3
Fixing Dockerfile.
Matthew-Mosior Dec 17, 2024
8ab2fa4
Fixing Haskell (Dockerfile and code).
Matthew-Mosior Dec 17, 2024
a75c1d8
Fixing scala.
Matthew-Mosior Dec 17, 2024
22789de
Fixing scala.
Matthew-Mosior Dec 17, 2024
60c2af1
Fix bf-staged.scala (get it up to date).
Matthew-Mosior Dec 18, 2024
3dd7cc6
Fixing bf.v (getting up to date).
Matthew-Mosior Dec 18, 2024
caaad24
Fixing Makefile.
Matthew-Mosior Dec 18, 2024
1adb0ce
Adding Idris2 mutable array version (in-progress) and updating Idris2…
Matthew-Mosior Feb 26, 2025
762ffde
Updating code.
Matthew-Mosior Mar 7, 2025
4249b93
Updating README.md.
Matthew-Mosior Mar 7, 2025
e9a41ee
Updating code.
Matthew-Mosior Mar 7, 2025
af7dfae
Updating code.
Matthew-Mosior Mar 7, 2025
d3e5b04
Updating code.
Matthew-Mosior Mar 7, 2025
96ec870
Removed unnecessary files and submodules.
Matthew-Mosior Mar 7, 2025
c42aa57
Removed unnecessary files and submodules.
Matthew-Mosior Mar 7, 2025
4b5dcaf
Updating code.
Matthew-Mosior Mar 7, 2025
8f9e257
Merge branch 'master' into idris2-json
Matthew-Mosior Mar 7, 2025
80b917b
Updating README.md.
Matthew-Mosior Mar 7, 2025
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: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "json/idris2-json-test"]
path = json/idris2-json-test
url = https://github.com/Matthew-Mosior/idris2-json-test
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ Base Docker image: Debian GNU/Linux trixie/sid
| Go | go1.23.2 |
| Go/gccgo | 14.2.0 |
| Haskell | 9.8.2 |
| Idris 2 | 0.6.0 |
| Idris 2 | 0.7.0 |
| Java | 23.0.1 |
| Julia | v"1.11.1" |
| Kotlin | 2.0.21 |
Expand Down Expand Up @@ -555,6 +555,12 @@ TCP connectivity between the tests and the test runner.
- [raw-strings-qq](http://hackage.haskell.org/package/raw-strings-qq) for
raw string literals used in tests.

For Idris2:
- [elab-util](https://github.com/stefan-hoeck/idris2-elab-util) for idris2-json-test.
- [parser-json](https://github.com/stefan-hoeck/idris2-parser/tree/main/json) for idris2-json-test.
- [ref1](https://github.com/stefan-hoeck/idris2-ref1) for idris2-json-test.
- [network](https://test.idris-lang.org/Idris2/network/) for TCP connectivity between the tests and the test runner.

For Perl:

- [cpanminus](https://metacpan.org/pod/App::cpanminus) for installing
Expand Down
7 changes: 2 additions & 5 deletions brainfuck/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ executables := \
target/bin_c_clang \
fsharp/target/Release/net8.0/brainfuck \
target/Release/net8.0/brainfuck \
target/bin_zig \
target/bin_idris
target/bin_zig

artifacts := $(executables) \
target/bf2-kt.jar \
Expand Down Expand Up @@ -151,16 +150,14 @@ target/bf.class: bf.java | target
target/bin_zig: bf.zig | $(zig_fmt)
$(ZIG_BUILD)

target/bin_idris: bf.idr | target
$(IDRIS_BUILD)

# Run

.PHONY: run
run: $(all_runners)

.PHONY: run2
run2: BF_SRC := mandel.b > /dev/null

run2: $(fast_runners)

## Common recipe for all runners
Expand Down
3 changes: 2 additions & 1 deletion brainfuck/bf-marray.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE ScopedTypeVariables #-}

Expand All @@ -17,7 +18,7 @@ import Network.Socket.ByteString
import System.Environment
import System.Exit
import System.IO (hFlush, stdout)
import System.Posix (getProcessID)
import "unix" System.Posix (getProcessID)
import Text.RawString.QQ

data Op = Inc !Int | Move !Int | Print | Loop ![Op] deriving Show
Expand Down
3 changes: 2 additions & 1 deletion brainfuck/bf.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE ScopedTypeVariables #-}

Expand All @@ -15,7 +16,7 @@ import Network.Socket.ByteString
import System.Environment
import System.Exit
import System.IO
import System.Posix (getProcessID)
import "unix" System.Posix (getProcessID)

data Op = Inc !Int | MoveLeft | MoveRight | Print | Loop [Op]
data Tape = Tape { left :: [Int], current :: !Int, right :: [Int] }
Expand Down
3 changes: 0 additions & 3 deletions brainfuck/bf.idr
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,16 @@ accCheckSum : Int -> (Int, Int) -> (Int, Int)
accCheckSum n (s₁, s₂) = let s₁' = (s₁ + n) `mod` 255
s₂' = (s₁' + s₂) `mod` 255
in (s₁', s₂')

-- For benchmark
Loud = IO
Ctx Loud where
write n = do
putChar (chr n)
fflush stdout

-- For checksum-ing
Quiet = State (Int, Int)
Ctx Quiet where
write n = modify (accCheckSum n)

partial
run : Ctx m => List Op -> Tape -> m Tape
run [] tape = pure tape
Expand Down
50 changes: 26 additions & 24 deletions common/commands.mk
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,34 @@ endef

ECHO_RUN = @tput bold; echo "$(MAKE) $@"; tput sgr0
XTIME := ../xtime.rb
XTIME_IDRIS := ../../xtime.rb
CPANM := cpanm -l ~/perl5

CLOJURE_RUN = $(XTIME) clojure $(CLOJURE_FLAGS) -M $^
ELIXIR_RUN = $(XTIME) elixir $^
EXECUTABLE_RUN = $(XTIME) $^
JAVA_CLASS_RUN = $(XTIME) java -cp $(^D) $(basename $(^F))
JAVA_JAR_RUN = $(XTIME) java -jar $^
JRUBY_RUN = $(XTIME) jruby $^
LUA_JIT_RUN = $(XTIME) luajit $^
LUA_RUN = $(XTIME) lua $^
MONO_RUN = $(XTIME) mono -O=all --gc=sgen $^
NODE_RUN = $(XTIME) node $^
PERL_RUN = $(XTIME) perl -I ~/perl5/lib/perl5 $^
PHP_RUN = $(XTIME) php $^
PYPY3_RUN = $(XTIME) pypy3 $^
PYTHON3_RUN = $(XTIME) python3 $^
RACKET_RUN = PLT_CS_COMPILE_LIMIT=100000 $(XTIME) racket $^
RUBY_JIT_RUN = $(XTIME) ruby --jit $^
RUBY_RUN = $(XTIME) ruby $^
SCALA_RUN = $(XTIME) scala $^
TCLSH_RUN = $(XTIME) tclsh $^
TRUBY_JVM_RUN = $(XTIME) truffleruby-jvm-bin $^
TRUBY_NATIVE_RUN = $(XTIME) truffleruby $^
SCHEME_RUN = $(XTIME) scheme --optimize-level 3 --program $^
JULIA_RUN = $(XTIME) julia --optimize=3 --check-bounds=no $^
PHP_RUN = $(XTIME) php $^
CLOJURE_RUN = $(XTIME) clojure $(CLOJURE_FLAGS) -M $^
ELIXIR_RUN = $(XTIME) elixir $^
EXECUTABLE_RUN = $(XTIME) $^
JAVA_CLASS_RUN = $(XTIME) java -cp $(^D) $(basename $(^F))
JAVA_JAR_RUN = $(XTIME) java -jar $^
JRUBY_RUN = $(XTIME) jruby $^
LUA_JIT_RUN = $(XTIME) luajit $^
LUA_RUN = $(XTIME) lua $^
MONO_RUN = $(XTIME) mono -O=all --gc=sgen $^
NODE_RUN = $(XTIME) node $^
PERL_RUN = $(XTIME) perl -I ~/perl5/lib/perl5 $^
PHP_RUN = $(XTIME) php $^
PYPY3_RUN = $(XTIME) pypy3 $^
PYTHON3_RUN = $(XTIME) python3 $^
RACKET_RUN = PLT_CS_COMPILE_LIMIT=100000 $(XTIME) racket $^
RUBY_JIT_RUN = $(XTIME) ruby --jit $^
RUBY_RUN = $(XTIME) ruby $^
SCALA_RUN = $(XTIME) scala $^
TCLSH_RUN = $(XTIME) tclsh $^
TRUBY_JVM_RUN = $(XTIME) truffleruby-jvm-bin $^
TRUBY_NATIVE_RUN = $(XTIME) truffleruby $^
SCHEME_RUN = $(XTIME) scheme --optimize-level 3 --program $^
JULIA_RUN = $(XTIME) julia --optimize=3 --check-bounds=no $^
PHP_RUN = $(XTIME) php $^
IDRIS_JSON_BUILD_AND_RUN = cd idris2-json-test && pack build && $(XTIME_IDRIS) pack run idris2-json-test.ipkg

GIT_CLONE = git clone --depth 1 -q
DOTNET_CLEAN = -dotnet clean --nologo -v q -c Release
Expand Down
43 changes: 27 additions & 16 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM debian:trixie-20241016-slim
FROM debian:trixie-20240701-slim


ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 \
DEBIAN_FRONTEND=noninteractive
Expand All @@ -10,7 +11,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
chezscheme \
clang-19 \
cmake \
cpanminus \
Expand All @@ -21,7 +21,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
gdc-14 \
git \
libblas-dev \
libboost-dev \
libc++-19-dev \
libc++abi-19-dev \
libevent-dev \
Expand All @@ -44,6 +43,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libssl-dev \
libtool \
libtool-bin \
libx11-dev \
libxml2 \
libyajl-dev \
libyaml-dev \
Expand Down Expand Up @@ -88,16 +88,22 @@ ENV PATH="/root/bin/:/root/.local/bin/:${PATH}" \
RUN curl -Lo /root/bin/coursier https://git.io/coursier-cli \
&& chmod +x /root/bin/coursier

# https://www.idris-lang.org/pages/download.html
ARG IDRIS=0.6.0
RUN curl https://www.idris-lang.org/idris2-src/idris2-$IDRIS.tgz | tar -xz
WORKDIR /root/bin/Idris2-$IDRIS
ENV PATH="/root/bin/idris2/bin:${PATH}"
ENV LD_LIBRARY_PATH="/root/bin/idris2/lib"
RUN PREFIX=/root/bin/idris2 make bootstrap SCHEME=chezscheme \
&& PREFIX=/root/bin/idris2 make install
# https://github.com/cisco/ChezScheme
WORKDIR /root/bin
RUN git clone https://github.com/cisco/ChezScheme.git
WORKDIR /root/bin/ChezScheme
RUN ./configure
RUN make
RUN make install

# https://github.com/stefan-hoeck/idris2-pack
ENV PACK_DIR="/root/bin/.pack"
WORKDIR /root/bin
RUN rm -rf Idris2-$IDRIS
RUN echo -e "scheme" | bash -c "$(curl -fsSL https://raw.githubusercontent.com/stefan-hoeck/idris2-pack/main/install.bash)"
ENV PATH="${PACK_DIR}/bin:${PACK_DIR}/.idris2/bin:${PATH}"
RUN pack install elab-util
RUN pack install parser-json
RUN pack install ref1

# https://www.ruby-lang.org/en/downloads/
ARG RUBY=ruby-3.3.5
Expand Down Expand Up @@ -247,15 +253,16 @@ ENV PATH="/root/bin/opam/ocaml-base-compiler.$OCAML/bin/:${PATH}"

# https://kotlinlang.org/docs/command-line.html
ARG KOTLIN=2.0.21
RUN curl -LO \
RUN curl -L -o kotlin-compiler-$KOTLIN.zip \
https://github.com/JetBrains/kotlin/releases/download/v$KOTLIN/kotlin-compiler-$KOTLIN.zip \
&& unzip kotlin-compiler-$KOTLIN.zip \
&& rm kotlin-compiler-$KOTLIN.zip
ENV PATH="/root/bin/kotlinc/bin/:${PATH}"

# https://download.racket-lang.org/
ARG RACKET=8.14
RUN curl -LO \
RUN curl -L -o racket-$RACKET-x86_64-linux-cs.sh \

https://download.racket-lang.org/installers/$RACKET/racket-$RACKET-x86_64-linux-cs.sh \
&& sh racket-$RACKET-x86_64-linux-cs.sh --unix-style --dest /root/ \
&& rm racket-$RACKET-x86_64-linux-cs.sh
Expand All @@ -280,7 +287,7 @@ ENV PATH="/root/bin/luajit/bin:${PATH}"

# https://github.com/vlang/v/releases
ARG VLANG=0.4.8
RUN curl -LO \
RUN curl -Lo v_linux.zip \
https://github.com/vlang/v/releases/download/$VLANG/v_linux.zip \
&& unzip -q v_linux.zip \
&& rm v_linux.zip
Expand Down Expand Up @@ -312,10 +319,14 @@ RUN ghcup install ghc $GHC_VER && ghcup set ghc $GHC_VER

# Shared packages for all Haskell code
RUN cabal update \
&& cabal install network raw-strings-qq unix bytestring array --lib \
&& cabal install bytestring-0.12.1.0 network-3.2.7.0 raw-strings-qq unix-2.8.6.0 array --lib \
&& cabal install hlint
ENV GHC_PACKAGE_PATH="~/.cabal/store/ghc-${GHC_VER}/package.db:"

# Hide unnecessary package (Haskell).
#RUN ghc-pkg hide bytestring-0.12.1.0
#RUN ghc-pkg hide unix-2.8.4.0

ARG SCRIPTS_VER=unknown
COPY *.rb ./

Expand Down
4 changes: 4 additions & 0 deletions json/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ artifacts := $(executables) \

# run[test.jl]
all_runners := $(patsubst %,run[%], $(artifacts)) \
run[idris2-json-test] \
run[test_yajl.rb] \
run[test.pl] \
run[test-xs.pl] \
Expand Down Expand Up @@ -411,6 +412,9 @@ run[test.clj]:: run[%]: %
run[test.rkt]:: run[%]: %
$(RACKET_RUN)

run[idris2-json-test]:: run[%]: %
$(IDRIS_JSON_BUILD_AND_RUN)

# Utilities

.PHONY: clean
Expand Down
1 change: 1 addition & 0 deletions json/idris2-json-test
Submodule idris2-json-test added at 119545