Skip to content

Commit 214f5dd

Browse files
authored
appveyor test (#1)
1 parent 50a64d2 commit 214f5dd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2602
-73
lines changed

.gitignore

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
# Created by https://www.toptal.com/developers/gitignore/api/vscode,osx
3+
# Edit at https://www.toptal.com/developers/gitignore?templates=vscode,osx
4+
5+
### OSX ###
6+
# General
7+
.DS_Store
8+
.AppleDouble
9+
.LSOverride
10+
11+
# Icon must end with two \r
12+
Icon
13+
14+
15+
# Thumbnails
16+
._*
17+
18+
# Files that might appear in the root of a volume
19+
.DocumentRevisions-V100
20+
.fseventsd
21+
.Spotlight-V100
22+
.TemporaryItems
23+
.Trashes
24+
.VolumeIcon.icns
25+
.com.apple.timemachine.donotpresent
26+
27+
# Directories potentially created on remote AFP share
28+
.AppleDB
29+
.AppleDesktop
30+
Network Trash Folder
31+
Temporary Items
32+
.apdisk
33+
34+
### vscode ###
35+
.vscode/*
36+
!.vscode/settings.json
37+
!.vscode/tasks.json
38+
!.vscode/launch.json
39+
!.vscode/extensions.json
40+
*.code-workspace
41+
42+
# End of https://www.toptal.com/developers/gitignore/api/vscode,osx

appveyor.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
version: 1.0.{build}
2+
image: Ubuntu2004
3+
pull_requests:
4+
do_not_increment_build_number: true
5+
branches:
6+
only:
7+
- main
8+
build: off
9+
cache:
10+
- /var/lib/docker
11+
- /home/appveyor/.cache/yarn/v6
12+
- /home/appveyor/.nuget/packages
13+
install:
14+
- nvm use 14
15+
- pushd website
16+
- yarn
17+
- popd
18+
build_script:
19+
- pushd bench
20+
- sudo dotnet run -c Release -p tool -- --task build --force-pull-docker true
21+
- sudo dotnet run -c Release -p tool -- --task test
22+
- sudo dotnet run -c Release -p tool -- --task bench
23+
- popd
24+
- pushd website
25+
- yarn
26+
- yarn content
27+
- yarn generate
28+
- popd
29+
artifacts:
30+
- path: bench/build
31+
name: benchmark
32+
- path: website/dist
33+
name: website

bench/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build
2+
.tmp

bench/algorithm/binarytrees/1.go

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/* The Computer Language Benchmarks Game
2+
* https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
3+
*
4+
* contributed by The Go Authors.
5+
* based on C program by Kevin Carson
6+
* flag.Arg hack by Isaac Gouy
7+
* *reset*
8+
*/
9+
10+
package main
11+
12+
import (
13+
"flag"
14+
"fmt"
15+
"strconv"
16+
)
17+
18+
var n = 0
19+
20+
type Node struct {
21+
left, right *Node
22+
}
23+
24+
func bottomUpTree(depth int) *Node {
25+
if depth <= 0 {
26+
return &Node{}
27+
}
28+
return &Node{bottomUpTree(depth - 1), bottomUpTree(depth - 1)}
29+
}
30+
31+
func (n *Node) itemCheck() int {
32+
if n.left == nil {
33+
return 1
34+
}
35+
return 1 + n.left.itemCheck() + n.right.itemCheck()
36+
}
37+
38+
const minDepth = 4
39+
40+
func main() {
41+
flag.Parse()
42+
if flag.NArg() > 0 {
43+
n, _ = strconv.Atoi(flag.Arg(0))
44+
}
45+
46+
maxDepth := n
47+
if minDepth+2 > n {
48+
maxDepth = minDepth + 2
49+
}
50+
stretchDepth := maxDepth + 1
51+
52+
check := bottomUpTree(stretchDepth).itemCheck()
53+
fmt.Printf("stretch tree of depth %d\t check: %d\n", stretchDepth, check)
54+
55+
longLivedTree := bottomUpTree(maxDepth)
56+
57+
for depth := minDepth; depth <= maxDepth; depth += 2 {
58+
iterations := 1 << uint(maxDepth-depth+minDepth)
59+
check = 0
60+
61+
for i := 1; i <= iterations; i++ {
62+
check += bottomUpTree(depth).itemCheck()
63+
}
64+
fmt.Printf("%d\t trees of depth %d\t check: %d\n", iterations, depth, check)
65+
}
66+
fmt.Printf("long lived tree of depth %d\t check: %d\n", maxDepth, longLivedTree.itemCheck())
67+
}

bench/algorithm/binarytrees/10_out

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
stretch tree of depth 11 check: 4095
2+
1024 trees of depth 4 check: 31744
3+
256 trees of depth 6 check: 32512
4+
64 trees of depth 8 check: 32704
5+
16 trees of depth 10 check: 32752
6+
long lived tree of depth 10 check: 2047

bench/algorithm/binarytrees/2.go

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/* The Computer Language Benchmarks Game
2+
* https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
3+
*
4+
* Contributed by Alexandr Karbivnichiy
5+
*/
6+
7+
package main
8+
9+
import (
10+
"flag"
11+
"fmt"
12+
"sort"
13+
"strconv"
14+
"sync"
15+
)
16+
17+
type Node struct {
18+
next *Next
19+
}
20+
21+
type Next struct {
22+
left, right Node
23+
}
24+
25+
func createTree(depth int) Node {
26+
if depth > 1 {
27+
return Node{&Next{createTree(depth - 1), createTree(depth - 1)}}
28+
}
29+
return Node{&Next{Node{}, Node{}}}
30+
}
31+
32+
func checkTree(node Node) int {
33+
sum := 1
34+
current := node.next
35+
for current != nil {
36+
sum += checkTree(current.right) + 1
37+
current = current.left.next
38+
}
39+
return sum
40+
}
41+
42+
func main() {
43+
n := 0
44+
flag.Parse()
45+
if flag.NArg() > 0 {
46+
n, _ = strconv.Atoi(flag.Arg(0))
47+
}
48+
run(n)
49+
}
50+
51+
func run(maxDepth int) {
52+
const minDepth = 4
53+
var longLivedTree Node
54+
var group sync.WaitGroup
55+
var messages sync.Map
56+
57+
if minDepth+2 > maxDepth {
58+
maxDepth = minDepth + 2
59+
}
60+
61+
group.Add(1)
62+
go func() {
63+
messages.Store(-1, fmt.Sprintf("stretch tree of depth %d\t check: %d",
64+
maxDepth+1, checkTree(createTree(maxDepth+1))))
65+
longLivedTree = createTree(maxDepth)
66+
group.Done()
67+
}()
68+
69+
for halfDepth := minDepth / 2; halfDepth < maxDepth/2+1; halfDepth++ {
70+
iters := 1 << (maxDepth - (halfDepth * 2) + minDepth)
71+
group.Add(1)
72+
go func(depth, iters, chk int) {
73+
for i := 0; i < iters; i++ {
74+
chk += checkTree(createTree(depth))
75+
}
76+
messages.Store(depth, fmt.Sprintf("%d\t trees of depth %d\t check: %d",
77+
iters, depth, chk))
78+
group.Done()
79+
}(halfDepth*2, iters, 0)
80+
}
81+
82+
group.Wait()
83+
84+
var idxs []int
85+
messages.Range(func(key, val interface{}) bool {
86+
idxs = append(idxs, key.(int))
87+
return true
88+
})
89+
sort.Ints(idxs)
90+
for _, idx := range idxs {
91+
msg, _ := messages.Load(idx)
92+
fmt.Println(msg)
93+
}
94+
95+
fmt.Printf("long lived tree of depth %d\t check: %d\n",
96+
maxDepth, checkTree(longLivedTree))
97+
}

bench/algorithm/binarytrees/2.java

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/* The Computer Language Benchmarks Game
2+
https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
3+
4+
contributed by Jarkko Miettinen
5+
*reset*
6+
*/
7+
8+
class binarytrees {
9+
10+
private final static int minDepth = 4;
11+
12+
public static void main(String[] args){
13+
int n = 0;
14+
if (args.length > 0) n = Integer.parseInt(args[0]);
15+
16+
int maxDepth = (minDepth + 2 > n) ? minDepth + 2 : n;
17+
int stretchDepth = maxDepth + 1;
18+
19+
int check = (TreeNode.bottomUpTree(stretchDepth)).itemCheck();
20+
System.out.println("stretch tree of depth "+stretchDepth+"\t check: " + check);
21+
22+
TreeNode longLivedTree = TreeNode.bottomUpTree(maxDepth);
23+
24+
for (int depth=minDepth; depth<=maxDepth; depth+=2){
25+
int iterations = 1 << (maxDepth - depth + minDepth);
26+
check = 0;
27+
28+
for (int i=1; i<=iterations; i++){
29+
check += (TreeNode.bottomUpTree(depth)).itemCheck();
30+
}
31+
System.out.println(iterations + "\t trees of depth " + depth + "\t check: " + check);
32+
}
33+
System.out.println("long lived tree of depth " + maxDepth + "\t check: "+ longLivedTree.itemCheck());
34+
}
35+
36+
37+
private static class TreeNode
38+
{
39+
private TreeNode left, right;
40+
41+
private static TreeNode bottomUpTree(int depth){
42+
if (depth>0){
43+
return new TreeNode(
44+
bottomUpTree(depth-1)
45+
, bottomUpTree(depth-1)
46+
);
47+
}
48+
else {
49+
return new TreeNode(null,null);
50+
}
51+
}
52+
53+
TreeNode(TreeNode left, TreeNode right){
54+
this.left = left;
55+
this.right = right;
56+
}
57+
58+
private int itemCheck(){
59+
// if necessary deallocate here
60+
if (left==null) return 1;
61+
else return 1 + left.itemCheck() + right.itemCheck();
62+
}
63+
}
64+
}

bench/algorithm/binarytrees/3.cs

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
namespace BenchmarkGameBTrees
2+
{
3+
/*
4+
The Computer Language Benchmarks Game
5+
https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
6+
7+
contributed by Marek Safar
8+
optimized by kasthack
9+
*reset*
10+
*/
11+
using System;
12+
using System.Threading;
13+
using System.Threading.Tasks;
14+
15+
class BinaryTrees
16+
{
17+
const int minDepth = 4;
18+
public static void Main(String[] args)
19+
{
20+
int n = 0;
21+
if (args.Length > 0) n = Int32.Parse(args[0]);
22+
int maxDepth = Math.Max(minDepth + 2, n);
23+
int stretchDepth = maxDepth + 1;
24+
int check = (TreeNode.bottomUpTree(stretchDepth)).itemCheck();
25+
Console.WriteLine("stretch tree of depth {0}\t check: {1}", stretchDepth, check);
26+
TreeNode longLivedTree = TreeNode.bottomUpTree(maxDepth);
27+
for (int depth = minDepth; depth <= maxDepth; depth += 2)
28+
{
29+
int iterations = 1 << (maxDepth - depth + minDepth);
30+
check = 0;
31+
32+
Parallel.For(1, iterations + 1,
33+
() => 0,
34+
(i, loop, localCheck) =>
35+
{
36+
return localCheck +
37+
(TreeNode.bottomUpTree(depth)).itemCheck();
38+
},
39+
localCheck => Interlocked.Add(ref check, localCheck)
40+
);
41+
42+
Console.WriteLine("{0}\t trees of depth {1}\t check: {2}",
43+
iterations, depth, check);
44+
}
45+
Console.WriteLine("long lived tree of depth {0}\t check: {1}",
46+
maxDepth, longLivedTree.itemCheck());
47+
}
48+
49+
class TreeNode
50+
{
51+
private TreeNode left, right;
52+
53+
internal static TreeNode bottomUpTree(int depth)
54+
{
55+
TreeNode t;
56+
ChildTreeNodes(out t, depth);
57+
return t;
58+
}
59+
static void ChildTreeNodes(out TreeNode node, int depth)
60+
{
61+
node = new TreeNode();
62+
if (depth > 0)
63+
{
64+
ChildTreeNodes(out node.left, depth - 1);
65+
ChildTreeNodes(out node.right, depth - 1);
66+
}
67+
}
68+
internal int itemCheck()
69+
{
70+
if (right == null) return 1;
71+
else return 1 + left.itemCheck() + right.itemCheck();
72+
}
73+
}
74+
}
75+
}

0 commit comments

Comments
 (0)