Skip to content

Commit b8266c0

Browse files
authored
feat: fix prod build (#21)
1 parent cf101c2 commit b8266c0

File tree

11 files changed

+278
-5
lines changed

11 files changed

+278
-5
lines changed

appveyor.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,22 @@ cache:
1919
- /home/appveyor/.udocker
2020
- /home/appveyor/.gradle
2121
- /home/appveyor/.konan
22+
- /home/appveyor/.stack
2223
install:
2324
- docker info
2425
- nvm use 14
2526
- python -V
27+
- curl -sSL https://get.haskellstack.org/ | sh
28+
# begin tmp vlang installation
29+
- git clone https://github.com/vlang/v /tmp/vlang
30+
- pushd /tmp/vlang
31+
- make && ./v -version
32+
- sudo ./v symlink
33+
- v -prod examples/hanoi.v
34+
# - ./examples/hanoi
35+
- popd
36+
- v -version
37+
# end tmp vlang installation
2638
- update-alternatives --list java
2739
- echo $JAVA_HOME
2840
- export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/
@@ -38,9 +50,9 @@ install:
3850
# - popd
3951
build_script:
4052
- pushd bench
41-
- dotnet run -c Release -p tool -- --task build #--langs swift
42-
- dotnet run -c Release -p tool -- --task test #--langs swift
43-
- dotnet run -c Release -p tool -- --task bench --fail-fast true #--langs swift
53+
- dotnet run -c Release -p tool -- --task build #--langs haskell --verbose true
54+
- dotnet run -c Release -p tool -- --task test #--langs haskell
55+
- dotnet run -c Release -p tool -- --task bench --fail-fast true #--langs haskell
4456
- popd
4557
- pushd website
4658
- yarn

bench/algorithm/binarytrees/1.hs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
--
2+
-- The Computer Language Benchmarks Game
3+
-- https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
4+
--
5+
-- Contributed by Don Stewart
6+
-- *reset*
7+
--
8+
9+
import System.Environment
10+
import Data.Bits
11+
import Text.Printf
12+
13+
--
14+
-- an artificially strict tree.
15+
--
16+
-- normally you would ensure the branches are lazy, but this benchmark
17+
-- requires strict allocation.
18+
--
19+
data Tree = Nil | Node !Int !Tree !Tree
20+
21+
minN = 4
22+
23+
io s n t = printf "%s of depth %d\t check: %d\n" s n t
24+
25+
main = do
26+
n <- getArgs >>= readIO . head
27+
let maxN = max (minN + 2) n
28+
stretchN = maxN + 1
29+
30+
-- stretch memory tree
31+
let c = check (make 0 stretchN)
32+
io "stretch tree" stretchN c
33+
34+
-- allocate a long lived tree
35+
let !long = make 0 maxN
36+
37+
-- allocate, walk, and deallocate many bottom-up binary trees
38+
let vs = depth minN maxN
39+
mapM_ (\((m,d,i)) -> io (show m ++ "\t trees") d i) vs
40+
41+
-- confirm the the long-lived binary tree still exists
42+
io "long lived tree" maxN (check long)
43+
44+
-- generate many trees
45+
depth :: Int -> Int -> [(Int,Int,Int)]
46+
depth d m
47+
| d <= m = (n,d,sumT d n 0) : depth (d+2) m
48+
| otherwise = []
49+
where n = 1 `shiftL` (m - d + minN)
50+
51+
-- allocate and check lots of trees
52+
sumT :: Int -> Int -> Int -> Int
53+
sumT d 0 t = t
54+
sumT d i t = sumT d (i-1) (t + a)
55+
where a = check (make 0 d)
56+
57+
58+
-- traverse the tree, counting up the nodes
59+
check :: Tree -> Int
60+
check Nil = 0
61+
check (Node i l r) = 1 + check l + check r
62+
63+
-- build a tree
64+
make :: Int -> Int -> Tree
65+
make i 0 = Node i Nil Nil
66+
make i d = Node i (make d d2) (make d2 d2)
67+
where d2 = d-1

bench/algorithm/helloworld/1.hs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import System.Environment
2+
import Text.Printf
3+
4+
main :: IO ()
5+
main = do
6+
args <- getArgs
7+
let n = length args
8+
let name = if n > 0 then head args else ""
9+
printf "Hello world %s!\n" name
10+

bench/algorithm/pidigits/4.hs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
-- The Computer Language Benchmarks Game
2+
-- https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
3+
-- contributed by Bryan O'Sullivan
4+
-- modified by Eugene Kirpichov: pidgits only generates
5+
-- the result string instead of printing it. For some
6+
-- reason, this gives a speedup.
7+
-- modified by W. Gordon Goodsman to do two divisions
8+
-- as per the new task requirements.
9+
10+
import System.Environment
11+
12+
pidgits n = 0 % (0 # (1,0,1)) where
13+
i%ds
14+
| i >= n = []
15+
| True = (concat h ++ "\t:" ++ show j ++ "\n") ++ j%t
16+
where k = i+10; j = min n k
17+
(h,t) | k > n = (take (n`mod`10) ds ++ replicate (k-n) " ",[])
18+
| True = splitAt 10 ds
19+
j # s | n>a || q/=r = k # t
20+
| True = show q : k # (n*10,(a-(q*d))*10,d) -- inline eliminateDigit
21+
where k = j+1; t@(n,a,d)=k&s; q=3$s; r=4$s -- two calls to extractDigit
22+
c$(n,a,d) = (c*n+a)`div`d -- extractDigit
23+
j&(n,a,d) = (n*j,(a+n*2)*y,d*y) where y=(j*2+1) -- nextDigit
24+
25+
main = putStr.pidgits.read.head =<< getArgs

bench/bench_haskell.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
lang: haskell
2+
problems:
3+
- name: helloworld
4+
source:
5+
- 1.hs
6+
- name: binarytrees
7+
source:
8+
- 1.hs
9+
- name: pidigits
10+
source:
11+
- 4.hs
12+
compiler_version_command: stack exec ghc -- --version
13+
compiler_version_regex:
14+
runtime_version_parameter:
15+
runtime_version_regex:
16+
source_rename_to: Main.hs
17+
environments:
18+
- os: linux
19+
compiler: ghc
20+
version: latest
21+
docker:
22+
include: haskell
23+
include_sub_dir: app
24+
before_build:
25+
- stack setup --allow-different-user
26+
build: stack build
27+
after_build:
28+
- cp ./.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/build/app-exe/app-exe ./out/_app
29+
out_dir: out
30+
run_cmd: _app

bench/bench_vlang.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ environments:
1515
- os: linux
1616
compiler: vlang
1717
version: latest
18-
docker: thevlang/vlang
18+
# docker: thevlang/vlang
1919
include:
20-
build: v _app.v && mv _app out/
20+
include_sub_dir: out
21+
build: v -prod out/_app.v
2122
out_dir: out
2223
run_cmd: _app

bench/include/haskell/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*
2+
!.gitignore
3+
!app.cabal
4+
!Setup.hs
5+
!stack.yaml
6+
!package.yaml

bench/include/haskell/Setup.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Distribution.Simple
2+
main = defaultMain

bench/include/haskell/app.cabal

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
cabal-version: 1.12
2+
3+
-- This file has been generated from package.yaml by hpack version 0.33.0.
4+
--
5+
-- see: https://github.com/sol/hpack
6+
--
7+
-- hash: 4262425e41f3276d7fe43600b5729de75476275836521019c29b7aa2eae295af
8+
9+
name: app
10+
version: 0.1.0.0
11+
build-type: Simple
12+
13+
library
14+
-- other-modules:
15+
-- Paths_app
16+
-- hs-source-dirs:
17+
-- src
18+
-- build-depends:
19+
-- base >=4.7 && <5
20+
-- default-language: Haskell2010
21+
22+
executable app-exe
23+
main-is: Main.hs
24+
other-modules:
25+
Paths_app
26+
hs-source-dirs:
27+
app
28+
ghc-options: -threaded -rtsopts -with-rtsopts=-N -XBangPatterns -XScopedTypeVariables
29+
build-depends:
30+
app
31+
, base >=4.7 && <5
32+
default-language: Haskell2010

bench/include/haskell/package.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: app
2+
version: 0.1.0.0
3+
4+
dependencies:
5+
- base >= 4.7 && < 5
6+
7+
# library:
8+
# source-dirs: src
9+
10+
executables:
11+
app-exe:
12+
main: Main.hs
13+
source-dirs: app
14+
ghc-options:
15+
- -threaded
16+
- -rtsopts
17+
- -with-rtsopts=-N
18+
- -XBangPatterns
19+
- -XScopedTypeVariables
20+
dependencies:
21+
- app

0 commit comments

Comments
 (0)