Skip to content
18 changes: 15 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,22 @@ cache:
- /home/appveyor/.udocker
- /home/appveyor/.gradle
- /home/appveyor/.konan
- /home/appveyor/.stack
install:
- docker info
- nvm use 14
- python -V
- curl -sSL https://get.haskellstack.org/ | sh
# begin tmp vlang installation
- git clone https://github.com/vlang/v /tmp/vlang
- pushd /tmp/vlang
- make && ./v -version
- sudo ./v symlink
- v -prod examples/hanoi.v
# - ./examples/hanoi
- popd
- v -version
# end tmp vlang installation
- update-alternatives --list java
- echo $JAVA_HOME
- export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/
Expand All @@ -38,9 +50,9 @@ install:
# - popd
build_script:
- pushd bench
- dotnet run -c Release -p tool -- --task build #--langs swift
- dotnet run -c Release -p tool -- --task test #--langs swift
- dotnet run -c Release -p tool -- --task bench --fail-fast true #--langs swift
- dotnet run -c Release -p tool -- --task build #--langs haskell --verbose true
- dotnet run -c Release -p tool -- --task test #--langs haskell
- dotnet run -c Release -p tool -- --task bench --fail-fast true #--langs haskell
- popd
- pushd website
- yarn
Expand Down
67 changes: 67 additions & 0 deletions bench/algorithm/binarytrees/1.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
--
-- The Computer Language Benchmarks Game
-- https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
--
-- Contributed by Don Stewart
-- *reset*
--

import System.Environment
import Data.Bits
import Text.Printf

--
-- an artificially strict tree.
--
-- normally you would ensure the branches are lazy, but this benchmark
-- requires strict allocation.
--
data Tree = Nil | Node !Int !Tree !Tree

minN = 4

io s n t = printf "%s of depth %d\t check: %d\n" s n t

main = do
n <- getArgs >>= readIO . head
let maxN = max (minN + 2) n
stretchN = maxN + 1

-- stretch memory tree
let c = check (make 0 stretchN)
io "stretch tree" stretchN c

-- allocate a long lived tree
let !long = make 0 maxN

-- allocate, walk, and deallocate many bottom-up binary trees
let vs = depth minN maxN
mapM_ (\((m,d,i)) -> io (show m ++ "\t trees") d i) vs

-- confirm the the long-lived binary tree still exists
io "long lived tree" maxN (check long)

-- generate many trees
depth :: Int -> Int -> [(Int,Int,Int)]
depth d m
| d <= m = (n,d,sumT d n 0) : depth (d+2) m
| otherwise = []
where n = 1 `shiftL` (m - d + minN)

-- allocate and check lots of trees
sumT :: Int -> Int -> Int -> Int
sumT d 0 t = t
sumT d i t = sumT d (i-1) (t + a)
where a = check (make 0 d)


-- traverse the tree, counting up the nodes
check :: Tree -> Int
check Nil = 0
check (Node i l r) = 1 + check l + check r

-- build a tree
make :: Int -> Int -> Tree
make i 0 = Node i Nil Nil
make i d = Node i (make d d2) (make d2 d2)
where d2 = d-1
10 changes: 10 additions & 0 deletions bench/algorithm/helloworld/1.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import System.Environment
import Text.Printf

main :: IO ()
main = do
args <- getArgs
let n = length args
let name = if n > 0 then head args else ""
printf "Hello world %s!\n" name

25 changes: 25 additions & 0 deletions bench/algorithm/pidigits/4.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- The Computer Language Benchmarks Game
-- https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
-- contributed by Bryan O'Sullivan
-- modified by Eugene Kirpichov: pidgits only generates
-- the result string instead of printing it. For some
-- reason, this gives a speedup.
-- modified by W. Gordon Goodsman to do two divisions
-- as per the new task requirements.

import System.Environment

pidgits n = 0 % (0 # (1,0,1)) where
i%ds
| i >= n = []
| True = (concat h ++ "\t:" ++ show j ++ "\n") ++ j%t
where k = i+10; j = min n k
(h,t) | k > n = (take (n`mod`10) ds ++ replicate (k-n) " ",[])
| True = splitAt 10 ds
j # s | n>a || q/=r = k # t
| True = show q : k # (n*10,(a-(q*d))*10,d) -- inline eliminateDigit
where k = j+1; t@(n,a,d)=k&s; q=3$s; r=4$s -- two calls to extractDigit
c$(n,a,d) = (c*n+a)`div`d -- extractDigit
j&(n,a,d) = (n*j,(a+n*2)*y,d*y) where y=(j*2+1) -- nextDigit

main = putStr.pidgits.read.head =<< getArgs
30 changes: 30 additions & 0 deletions bench/bench_haskell.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
lang: haskell
problems:
- name: helloworld
source:
- 1.hs
- name: binarytrees
source:
- 1.hs
- name: pidigits
source:
- 4.hs
compiler_version_command: stack exec ghc -- --version
compiler_version_regex:
runtime_version_parameter:
runtime_version_regex:
source_rename_to: Main.hs
environments:
- os: linux
compiler: ghc
version: latest
docker:
include: haskell
include_sub_dir: app
before_build:
- stack setup --allow-different-user
build: stack build
after_build:
- cp ./.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/build/app-exe/app-exe ./out/_app
out_dir: out
run_cmd: _app
5 changes: 3 additions & 2 deletions bench/bench_vlang.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ environments:
- os: linux
compiler: vlang
version: latest
docker: thevlang/vlang
# docker: thevlang/vlang
include:
build: v _app.v && mv _app out/
include_sub_dir: out
build: v -prod out/_app.v
out_dir: out
run_cmd: _app
6 changes: 6 additions & 0 deletions bench/include/haskell/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*
!.gitignore
!app.cabal
!Setup.hs
!stack.yaml
!package.yaml
2 changes: 2 additions & 0 deletions bench/include/haskell/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
32 changes: 32 additions & 0 deletions bench/include/haskell/app.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.33.0.
--
-- see: https://github.com/sol/hpack
--
-- hash: 4262425e41f3276d7fe43600b5729de75476275836521019c29b7aa2eae295af

name: app
version: 0.1.0.0
build-type: Simple

library
-- other-modules:
-- Paths_app
-- hs-source-dirs:
-- src
-- build-depends:
-- base >=4.7 && <5
-- default-language: Haskell2010

executable app-exe
main-is: Main.hs
other-modules:
Paths_app
hs-source-dirs:
app
ghc-options: -threaded -rtsopts -with-rtsopts=-N -XBangPatterns -XScopedTypeVariables
build-depends:
app
, base >=4.7 && <5
default-language: Haskell2010
21 changes: 21 additions & 0 deletions bench/include/haskell/package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: app
version: 0.1.0.0

dependencies:
- base >= 4.7 && < 5

# library:
# source-dirs: src

executables:
app-exe:
main: Main.hs
source-dirs: app
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
- -XBangPatterns
- -XScopedTypeVariables
dependencies:
- app
67 changes: 67 additions & 0 deletions bench/include/haskell/stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# This file was automatically generated by 'stack init'
#
# Some commonly used options have been documented as comments in this file.
# For advanced use and comprehensive documentation of the format, please see:
# https://docs.haskellstack.org/en/stable/yaml_configuration/

# Resolver to choose a 'specific' stackage snapshot or a compiler version.
# A snapshot resolver dictates the compiler version and the set of packages
# to be used for project dependencies. For example:
#
# resolver: lts-3.5
# resolver: nightly-2015-09-21
# resolver: ghc-7.10.2
#
# The location of a snapshot can be provided as a file or url. Stack assumes
# a snapshot provided as a file might change, whereas a url resource does not.
#
# resolver: ./custom-snapshot.yaml
# resolver: https://example.com/snapshots/2018-01-01.yaml
resolver:
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/17/0.yaml

# User packages to be built.
# Various formats can be used as shown in the example below.
#
# packages:
# - some-directory
# - https://example.com/foo/bar/baz-0.0.2.tar.gz
# subdirs:
# - auto-update
# - wai
packages:
- .
# Dependency packages to be pulled from upstream that are not in the resolver.
# These entries can reference officially published versions as well as
# forks / in-progress versions pinned to a git hash. For example:
#
# extra-deps:
# - acme-missiles-0.3
# - git: https://github.com/commercialhaskell/stack.git
# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
#
# extra-deps: []

# Override default flag values for local packages and extra-deps
# flags: {}

# Extra package databases containing global packages
# extra-package-dbs: []

# Control whether we use the GHC we find on the path
# system-ghc: true
#
# Require a specific version of stack, using version ranges
# require-stack-version: -any # Default
# require-stack-version: ">=2.5"
#
# Override the architecture used by stack, especially useful on Windows
# arch: i386
# arch: x86_64
#
# Extra directories used by stack for building
# extra-include-dirs: [/path/to/dir]
# extra-lib-dirs: [/path/to/dir]
#
# Allow a newer minor version of GHC than the snapshot specifies
# compiler-check: newer-minor