Skip to content
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

Add Dictu to benchmark suite along with some contributing notes #8

Merged
merged 3 commits into from May 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/build.yml
Expand Up @@ -33,6 +33,14 @@ jobs:
echo './core.horse64.org/horsec run $1' > ../horse64
chmod +x ../horse64

- name: Dictu
run: |
git clone https://github.com/dictu-lang/Dictu.git
cd Dictu
cmake -DCMAKE_BUILD_TYPE=Release -DDISABLE_HTTP=1 -B ./build
cmake --build ./build
chmod +x ./dictu

- uses: actions/cache@v1
name: Wren [ cache ]
id: wren
Expand Down Expand Up @@ -98,6 +106,7 @@ jobs:
export PATH=./lua:$PATH
export PATH=./mdr:$PATH
export PATH=./Gwion:$PATH
export PATH=./Dictu:$PATH
export PATH=.:$PATH
git checkout results
git pull origin
Expand Down
11 changes: 11 additions & 0 deletions README.md
Expand Up @@ -2,3 +2,14 @@

Tools to run a benchmark of Gwion compared to other languages.
Find the [latest results here](https://gwion.github.io/Gwion/Benchmarks.html).

# Contributing

To add extra languages to the benchmarks follow these easy steps.

- Fork and clone this repository
- Setup all of the required tests in the `src/` directory written in the language you wish to add
- In [build.yml](.github/workflows/build.yml) add the build steps for the language
- Example setup [here](.github/workflows/build.yml#L27-L34)
- In [benchmark.sh](benchmark.sh) add the language along with the language file extension to the two relevant arrays at the top of the file
- In [version.sh](version.sh) add the version of the language which is being benchmarked
4 changes: 2 additions & 2 deletions benchmark.sh 100644 → 100755
@@ -1,7 +1,7 @@
#!/bin/bash

language=("gwion" "wren" "lua" "python" "chuck" "ruby" "horse64")
extension=("gw" "wren" "lua" "py" "ck" "rb" "h64")
language=("gwion" "wren" "lua" "python" "chuck" "ruby" "horse64", "dictu")
extension=("gw" "wren" "lua" "py" "ck" "rb" "h64", "du")
test_dir="src"
result_dir="results"
plot_script="bench.plot"
Expand Down
56 changes: 56 additions & 0 deletions src/binary-trees.du
@@ -0,0 +1,56 @@
class Tree {
init(item, depth) {
this.item = item;
this.depth = depth;
if (depth > 0) {
const item2 = item + item;
depth = depth - 1;
this.left = Tree(item2 - 1, depth);
this.right = Tree(item2, depth);
} else {
this.left = nil;
this.right = nil;
}
}

check() {
if (this.left == nil) {
return this.item;
}

return this.item + this.left.check() - this.right.check();
}
}

const minDepth = 4;
const maxDepth = 12;
const stretchDepth = maxDepth + 1;

const start = System.clock();

print("stretch tree of depth: {}".format(stretchDepth));

const longLivedTree = Tree(0, maxDepth);

var iterations = 1;

for (var d = 0; d < maxDepth; d += 1) {
iterations = iterations * 2;
}

var depth = minDepth;
while (depth < stretchDepth) {
var check = 0;
var i = 1;
while (i <= iterations) {
check = check + Tree(i, depth).check() + Tree(-i, depth).check();
i = i + 1;
}

print("Num trees: {} Depth: {} Check: {} Time: {}".format(iterations * 2, depth, check, System.clock() - start));

iterations = iterations / 4;
depth = depth + 2;
}

print("Long lived tree of depth: {} Check: {}".format(maxDepth, longLivedTree.check()));
9 changes: 9 additions & 0 deletions src/fib-recurs.du
@@ -0,0 +1,9 @@
def fibonacci(num) {
if (num < 2) {
return num;
}

return fibonacci(num - 2) + fibonacci(num - 1);
}

print(fibonacci(40));
12 changes: 12 additions & 0 deletions src/fib.du
@@ -0,0 +1,12 @@
def fibonacci(num) {
if (num < 2) {
return num;
}

return fibonacci(num - 2) + fibonacci(num - 1);
}

for (var i = 0; i < 5; i += 1) {
print(fibonacci(28));
}

13 changes: 13 additions & 0 deletions src/for.du
@@ -0,0 +1,13 @@
const list = [];

for (var i = 0; i < 1000000; i += 1) {
list.push(i);
}

var sum = 0;

for (var i = 0; i < 1000000; i += 1) {
sum += list[i];
}

print(sum);
67 changes: 67 additions & 0 deletions src/method-call.du
@@ -0,0 +1,67 @@
class Toggle {
init(startState) {
this.state = startState;
}

value() { return this.state; }

activate() {
this.state = !this.state;
return this;
}
}

class NthToggle < Toggle {
init(startState, maxCounter) {
super.init(startState);
this.countMax = maxCounter;
this.count = 0;
}

activate() {
this.count = this.count + 1;
if (this.count >= this.countMax) {
super.activate();
this.count = 0;
}

return this;
}
}

var val = true;
const n = 100000;
const toggle = Toggle(val);

for (var i = 0; i < n; i = i + 1) {
val = toggle.activate().value();
val = toggle.activate().value();
val = toggle.activate().value();
val = toggle.activate().value();
val = toggle.activate().value();
val = toggle.activate().value();
val = toggle.activate().value();
val = toggle.activate().value();
val = toggle.activate().value();
val = toggle.activate().value();
}

print(toggle.value());

val = true;
const ntoggle = NthToggle(val, 3);

for (var i = 0; i < n; i = i + 1) {
val = ntoggle.activate().value();
val = ntoggle.activate().value();
val = ntoggle.activate().value();
val = ntoggle.activate().value();
val = ntoggle.activate().value();
val = ntoggle.activate().value();
val = ntoggle.activate().value();
val = ntoggle.activate().value();
val = ntoggle.activate().value();
val = ntoggle.activate().value();
}

print(ntoggle.value());
35 changes: 35 additions & 0 deletions src/string-equals.du
@@ -0,0 +1,35 @@
var count = 0;

for (var i = 0; i < 1000000; i += 1) {
if ("abc" == "abc")
count = count + 1;

if ("a slightly longer string" == "a slightly longer string")
count = count + 1;

if ("a significantly longer string but still not overwhelmingly long string" ==
"a significantly longer string but still not overwhelmingly long string")
count = count + 1;

if ("" == "abc")
count = count + 1;

if ("abc" == "abcd")
count = count + 1;

if ("changed one character" == "changed !ne character")
count = count + 1;

if ("a slightly longer string" ==
"a slightly longer string!")
count = count + 1;

if ("a slightly longer string" ==
"a slightly longer strinh")
count = count + 1;

if ("a significantly longer string but still not overwhelmingly long string" == "another")
count = count + 1;
}

print(count);
1 change: 1 addition & 0 deletions version.sh
Expand Up @@ -8,4 +8,5 @@ python: $(python --version [ cut -d" " -f2)
chuck: $(chuck --version 2>&1 | head -2 | tail -1 | cut -d " " -f 3-5)
ruby: $(ruby -v | cut -d" " -f2)
horse64: $(horse64 --short-version)
dictu: $(dictu -v)
EOF