From 9b9465d299857ffa630bffe14f06c328874f1c88 Mon Sep 17 00:00:00 2001 From: Sebastian Ullrich Date: Wed, 29 May 2019 16:06:06 +0200 Subject: [PATCH] chore(tests/bench): move out from playground/ --- tests/bench/.gitignore | 5 ++++ tests/{playground => bench}/Makefile | 0 tests/{playground => bench}/arith_eval.ml | 0 .../binarytrees.ghc-6.hs | 0 tests/{playground => bench}/binarytrees.lean | 0 .../binarytrees.ocaml-2.ml | 0 tests/bench/compile.sh | 28 +++++++++++++++++++ .../bench.nix => bench/default.nix} | 0 tests/{playground => bench}/deriv.hs | 0 tests/{playground => bench}/deriv.lean | 0 tests/{playground => bench}/deriv.ml | 0 tests/{playground => bench}/deriv.sml | 0 .../expr_const_folding.hs | 0 .../expr_const_folding.lean | 0 .../expr_const_folding.ml | 0 .../expr_const_folding.sml | 0 .../expr_const_folding.swift | 0 .../{playground => bench}/frontend_test.lean | 0 tests/{playground => bench}/ghc-gc.py | 0 tests/{playground => bench}/lean-gc.py | 0 tests/bench/leanpkg.path | 2 ++ tests/{playground => bench}/mlkit-gc.py | 0 tests/{playground => bench}/nixpkgs.nix | 0 tests/{playground => bench}/ocaml-gc.py | 0 tests/{playground => bench}/perf.py | 0 tests/{playground => bench}/qsort.hs | 0 tests/{playground => bench}/qsort.lean | 0 tests/{playground => bench}/qsort.ml | 0 tests/{playground => bench}/qsort.sml | 0 tests/{playground => bench}/rbmap.hs | 0 tests/{playground => bench}/rbmap.lean | 0 .../{playground => bench}/rbmap.library.lean | 0 tests/{playground => bench}/rbmap.ml | 0 tests/{playground => bench}/rbmap.sml | 0 tests/{playground => bench}/rbmap2.lean | 0 tests/{playground => bench}/rbmap3.lean | 0 tests/{playground => bench}/rbmap4.lean | 0 .../{playground => bench}/rbmap_checkpoint.hs | 0 .../rbmap_checkpoint.lean | 0 .../{playground => bench}/rbmap_checkpoint.ml | 0 .../rbmap_checkpoint.sml | 0 .../rbmap_checkpoint2.lean | 0 .../rbmap_checkpoint2.sml | 0 tests/{playground => bench}/report.py | 0 tests/bench/run.sh | 9 ++++++ tests/{playground => bench}/temci.yaml | 0 tests/{playground => bench}/unionfind1.lean | 0 tests/{playground => bench}/unionfind2.lean | 0 tests/playground/bad_bench | 5 ---- tests/playground/build.nix | 26 ----------------- 50 files changed, 44 insertions(+), 31 deletions(-) create mode 100644 tests/bench/.gitignore rename tests/{playground => bench}/Makefile (100%) rename tests/{playground => bench}/arith_eval.ml (100%) rename tests/{playground => bench}/binarytrees.ghc-6.hs (100%) rename tests/{playground => bench}/binarytrees.lean (100%) rename tests/{playground => bench}/binarytrees.ocaml-2.ml (100%) create mode 100755 tests/bench/compile.sh rename tests/{playground/bench.nix => bench/default.nix} (100%) rename tests/{playground => bench}/deriv.hs (100%) rename tests/{playground => bench}/deriv.lean (100%) rename tests/{playground => bench}/deriv.ml (100%) rename tests/{playground => bench}/deriv.sml (100%) rename tests/{playground => bench}/expr_const_folding.hs (100%) rename tests/{playground => bench}/expr_const_folding.lean (100%) rename tests/{playground => bench}/expr_const_folding.ml (100%) rename tests/{playground => bench}/expr_const_folding.sml (100%) rename tests/{playground => bench}/expr_const_folding.swift (100%) rename tests/{playground => bench}/frontend_test.lean (100%) rename tests/{playground => bench}/ghc-gc.py (100%) rename tests/{playground => bench}/lean-gc.py (100%) create mode 100644 tests/bench/leanpkg.path rename tests/{playground => bench}/mlkit-gc.py (100%) rename tests/{playground => bench}/nixpkgs.nix (100%) rename tests/{playground => bench}/ocaml-gc.py (100%) rename tests/{playground => bench}/perf.py (100%) rename tests/{playground => bench}/qsort.hs (100%) rename tests/{playground => bench}/qsort.lean (100%) rename tests/{playground => bench}/qsort.ml (100%) rename tests/{playground => bench}/qsort.sml (100%) rename tests/{playground => bench}/rbmap.hs (100%) rename tests/{playground => bench}/rbmap.lean (100%) rename tests/{playground => bench}/rbmap.library.lean (100%) rename tests/{playground => bench}/rbmap.ml (100%) rename tests/{playground => bench}/rbmap.sml (100%) rename tests/{playground => bench}/rbmap2.lean (100%) rename tests/{playground => bench}/rbmap3.lean (100%) rename tests/{playground => bench}/rbmap4.lean (100%) rename tests/{playground => bench}/rbmap_checkpoint.hs (100%) rename tests/{playground => bench}/rbmap_checkpoint.lean (100%) rename tests/{playground => bench}/rbmap_checkpoint.ml (100%) rename tests/{playground => bench}/rbmap_checkpoint.sml (100%) rename tests/{playground => bench}/rbmap_checkpoint2.lean (100%) rename tests/{playground => bench}/rbmap_checkpoint2.sml (100%) rename tests/{playground => bench}/report.py (100%) create mode 100755 tests/bench/run.sh rename tests/{playground => bench}/temci.yaml (100%) rename tests/{playground => bench}/unionfind1.lean (100%) rename tests/{playground => bench}/unionfind2.lean (100%) delete mode 100755 tests/playground/bad_bench delete mode 100644 tests/playground/build.nix diff --git a/tests/bench/.gitignore b/tests/bench/.gitignore new file mode 100644 index 0000000000..e0d0bf25c3 --- /dev/null +++ b/tests/bench/.gitignore @@ -0,0 +1,5 @@ +*.out +*.lean.cpp +*.cmi +*.cmx +*.o \ No newline at end of file diff --git a/tests/playground/Makefile b/tests/bench/Makefile similarity index 100% rename from tests/playground/Makefile rename to tests/bench/Makefile diff --git a/tests/playground/arith_eval.ml b/tests/bench/arith_eval.ml similarity index 100% rename from tests/playground/arith_eval.ml rename to tests/bench/arith_eval.ml diff --git a/tests/playground/binarytrees.ghc-6.hs b/tests/bench/binarytrees.ghc-6.hs similarity index 100% rename from tests/playground/binarytrees.ghc-6.hs rename to tests/bench/binarytrees.ghc-6.hs diff --git a/tests/playground/binarytrees.lean b/tests/bench/binarytrees.lean similarity index 100% rename from tests/playground/binarytrees.lean rename to tests/bench/binarytrees.lean diff --git a/tests/playground/binarytrees.ocaml-2.ml b/tests/bench/binarytrees.ocaml-2.ml similarity index 100% rename from tests/playground/binarytrees.ocaml-2.ml rename to tests/bench/binarytrees.ocaml-2.ml diff --git a/tests/bench/compile.sh b/tests/bench/compile.sh new file mode 100755 index 0000000000..fa2a5133a0 --- /dev/null +++ b/tests/bench/compile.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +if [ $# -eq 0 ]; then + echo "Usage: compile.sh [file]" + exit 1 +fi +ulimit -s 8192 +BIN_DIR=../../bin +LEAN=$BIN_DIR/lean +export LEAN_PATH=../../library:. +ff=$1 + +if [[ "$OSTYPE" == "msys" ]]; then + # Windows running MSYS2 + # Replace /c/ with c:, and / with \\ + ff=$(echo $ff | sed 's|^/\([a-z]\)/|\1:/|' | sed 's|/|\\\\|g') +fi + +$LEAN --cpp="$ff".cpp "$ff" +if [ $? -ne 0 ]; then + echo "Failed to compile $ff into C++ file" + exit 1 +fi + +$BIN_DIR/leanc -O3 -o "$ff.out" $ff.cpp +if [ $? -ne 0 ]; then + echo "Failed to compile C++ file $ff.cpp" + exit 1 +fi diff --git a/tests/playground/bench.nix b/tests/bench/default.nix similarity index 100% rename from tests/playground/bench.nix rename to tests/bench/default.nix diff --git a/tests/playground/deriv.hs b/tests/bench/deriv.hs similarity index 100% rename from tests/playground/deriv.hs rename to tests/bench/deriv.hs diff --git a/tests/playground/deriv.lean b/tests/bench/deriv.lean similarity index 100% rename from tests/playground/deriv.lean rename to tests/bench/deriv.lean diff --git a/tests/playground/deriv.ml b/tests/bench/deriv.ml similarity index 100% rename from tests/playground/deriv.ml rename to tests/bench/deriv.ml diff --git a/tests/playground/deriv.sml b/tests/bench/deriv.sml similarity index 100% rename from tests/playground/deriv.sml rename to tests/bench/deriv.sml diff --git a/tests/playground/expr_const_folding.hs b/tests/bench/expr_const_folding.hs similarity index 100% rename from tests/playground/expr_const_folding.hs rename to tests/bench/expr_const_folding.hs diff --git a/tests/playground/expr_const_folding.lean b/tests/bench/expr_const_folding.lean similarity index 100% rename from tests/playground/expr_const_folding.lean rename to tests/bench/expr_const_folding.lean diff --git a/tests/playground/expr_const_folding.ml b/tests/bench/expr_const_folding.ml similarity index 100% rename from tests/playground/expr_const_folding.ml rename to tests/bench/expr_const_folding.ml diff --git a/tests/playground/expr_const_folding.sml b/tests/bench/expr_const_folding.sml similarity index 100% rename from tests/playground/expr_const_folding.sml rename to tests/bench/expr_const_folding.sml diff --git a/tests/playground/expr_const_folding.swift b/tests/bench/expr_const_folding.swift similarity index 100% rename from tests/playground/expr_const_folding.swift rename to tests/bench/expr_const_folding.swift diff --git a/tests/playground/frontend_test.lean b/tests/bench/frontend_test.lean similarity index 100% rename from tests/playground/frontend_test.lean rename to tests/bench/frontend_test.lean diff --git a/tests/playground/ghc-gc.py b/tests/bench/ghc-gc.py similarity index 100% rename from tests/playground/ghc-gc.py rename to tests/bench/ghc-gc.py diff --git a/tests/playground/lean-gc.py b/tests/bench/lean-gc.py similarity index 100% rename from tests/playground/lean-gc.py rename to tests/bench/lean-gc.py diff --git a/tests/bench/leanpkg.path b/tests/bench/leanpkg.path new file mode 100644 index 0000000000..a46b9ab3fb --- /dev/null +++ b/tests/bench/leanpkg.path @@ -0,0 +1,2 @@ +builtin_path +path . \ No newline at end of file diff --git a/tests/playground/mlkit-gc.py b/tests/bench/mlkit-gc.py similarity index 100% rename from tests/playground/mlkit-gc.py rename to tests/bench/mlkit-gc.py diff --git a/tests/playground/nixpkgs.nix b/tests/bench/nixpkgs.nix similarity index 100% rename from tests/playground/nixpkgs.nix rename to tests/bench/nixpkgs.nix diff --git a/tests/playground/ocaml-gc.py b/tests/bench/ocaml-gc.py similarity index 100% rename from tests/playground/ocaml-gc.py rename to tests/bench/ocaml-gc.py diff --git a/tests/playground/perf.py b/tests/bench/perf.py similarity index 100% rename from tests/playground/perf.py rename to tests/bench/perf.py diff --git a/tests/playground/qsort.hs b/tests/bench/qsort.hs similarity index 100% rename from tests/playground/qsort.hs rename to tests/bench/qsort.hs diff --git a/tests/playground/qsort.lean b/tests/bench/qsort.lean similarity index 100% rename from tests/playground/qsort.lean rename to tests/bench/qsort.lean diff --git a/tests/playground/qsort.ml b/tests/bench/qsort.ml similarity index 100% rename from tests/playground/qsort.ml rename to tests/bench/qsort.ml diff --git a/tests/playground/qsort.sml b/tests/bench/qsort.sml similarity index 100% rename from tests/playground/qsort.sml rename to tests/bench/qsort.sml diff --git a/tests/playground/rbmap.hs b/tests/bench/rbmap.hs similarity index 100% rename from tests/playground/rbmap.hs rename to tests/bench/rbmap.hs diff --git a/tests/playground/rbmap.lean b/tests/bench/rbmap.lean similarity index 100% rename from tests/playground/rbmap.lean rename to tests/bench/rbmap.lean diff --git a/tests/playground/rbmap.library.lean b/tests/bench/rbmap.library.lean similarity index 100% rename from tests/playground/rbmap.library.lean rename to tests/bench/rbmap.library.lean diff --git a/tests/playground/rbmap.ml b/tests/bench/rbmap.ml similarity index 100% rename from tests/playground/rbmap.ml rename to tests/bench/rbmap.ml diff --git a/tests/playground/rbmap.sml b/tests/bench/rbmap.sml similarity index 100% rename from tests/playground/rbmap.sml rename to tests/bench/rbmap.sml diff --git a/tests/playground/rbmap2.lean b/tests/bench/rbmap2.lean similarity index 100% rename from tests/playground/rbmap2.lean rename to tests/bench/rbmap2.lean diff --git a/tests/playground/rbmap3.lean b/tests/bench/rbmap3.lean similarity index 100% rename from tests/playground/rbmap3.lean rename to tests/bench/rbmap3.lean diff --git a/tests/playground/rbmap4.lean b/tests/bench/rbmap4.lean similarity index 100% rename from tests/playground/rbmap4.lean rename to tests/bench/rbmap4.lean diff --git a/tests/playground/rbmap_checkpoint.hs b/tests/bench/rbmap_checkpoint.hs similarity index 100% rename from tests/playground/rbmap_checkpoint.hs rename to tests/bench/rbmap_checkpoint.hs diff --git a/tests/playground/rbmap_checkpoint.lean b/tests/bench/rbmap_checkpoint.lean similarity index 100% rename from tests/playground/rbmap_checkpoint.lean rename to tests/bench/rbmap_checkpoint.lean diff --git a/tests/playground/rbmap_checkpoint.ml b/tests/bench/rbmap_checkpoint.ml similarity index 100% rename from tests/playground/rbmap_checkpoint.ml rename to tests/bench/rbmap_checkpoint.ml diff --git a/tests/playground/rbmap_checkpoint.sml b/tests/bench/rbmap_checkpoint.sml similarity index 100% rename from tests/playground/rbmap_checkpoint.sml rename to tests/bench/rbmap_checkpoint.sml diff --git a/tests/playground/rbmap_checkpoint2.lean b/tests/bench/rbmap_checkpoint2.lean similarity index 100% rename from tests/playground/rbmap_checkpoint2.lean rename to tests/bench/rbmap_checkpoint2.lean diff --git a/tests/playground/rbmap_checkpoint2.sml b/tests/bench/rbmap_checkpoint2.sml similarity index 100% rename from tests/playground/rbmap_checkpoint2.sml rename to tests/bench/rbmap_checkpoint2.sml diff --git a/tests/playground/report.py b/tests/bench/report.py similarity index 100% rename from tests/playground/report.py rename to tests/bench/report.py diff --git a/tests/bench/run.sh b/tests/bench/run.sh new file mode 100755 index 0000000000..cdc955f8b5 --- /dev/null +++ b/tests/bench/run.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +if [ $# -eq 0 ]; then + echo "Usage: run.sh [file] [args]*" + exit 1 +fi +ff=$1 +./compile.sh $ff +shift 1 +time "./$ff.out" $* diff --git a/tests/playground/temci.yaml b/tests/bench/temci.yaml similarity index 100% rename from tests/playground/temci.yaml rename to tests/bench/temci.yaml diff --git a/tests/playground/unionfind1.lean b/tests/bench/unionfind1.lean similarity index 100% rename from tests/playground/unionfind1.lean rename to tests/bench/unionfind1.lean diff --git a/tests/playground/unionfind2.lean b/tests/bench/unionfind2.lean similarity index 100% rename from tests/playground/unionfind2.lean rename to tests/bench/unionfind2.lean diff --git a/tests/playground/bad_bench b/tests/playground/bad_bench deleted file mode 100755 index 5e807a858a..0000000000 --- a/tests/playground/bad_bench +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -for bench in "$@"; do - echo "benchmarking $bench" - time $bench >/dev/null -done diff --git a/tests/playground/build.nix b/tests/playground/build.nix deleted file mode 100644 index ee5e8cf025..0000000000 --- a/tests/playground/build.nix +++ /dev/null @@ -1,26 +0,0 @@ -{ pkgs ? import ./nixpkgs.nix }: - -let - lean = cmakeFlags: (pkgs.callPackage ../../default.nix { stdenv = pkgs.llvmPackages_7.stdenv; }).overrideAttrs (_: { inherit cmakeFlags; }); - ghc = hsPkgs: (pkgs.haskellPackages.ghcWithPackages hsPkgs).override { ghc = pkgs.haskell.compiler.ghc865; withLLVM = true; }; - ocaml = pkgs.ocaml-ng.ocamlPackages_4_07.ocaml; - # note that this will need to be compiled from source - ocamlFlambda = ocaml.override { flambdaSupport = true; }; -in { - buildLean = { name, src, cmakeFlags ? "", leancFlags ? "-O3" }: pkgs.stdenv.mkDerivation { - inherit name src; - buildCommand = "${lean cmakeFlags}/bin/lean --cpp=$src.cpp $src && ${lean cmakeFlags}/bin/leanc $src.cpp -o $out"; - }; - buildHs = { name, src, opts, hsPkgs ? (p : []) }: pkgs.stdenv.mkDerivation { - inherit name src; - buildCommand = "${ghc hsPkgs}/bin/ghc ${opts} $src -o $out"; - }; - buildOCaml = { name, src, opts }: pkgs.stdenv.mkDerivation { - inherit name src; - buildCommand = "${ocaml}/bin/ocamlopt.opt ${opts} $src -o $out"; - }; - buildOCamlFlambda = { name, src, opts }: pkgs.stdenv.mkDerivation { - inherit name src; - buildCommand = "${ocamlFlambda}/bin/ocamlopt.opt ${opts} $src -o $out"; - }; -}