Skip to content

Commit

Permalink
Maintenance update (#261)
Browse files Browse the repository at this point in the history
* Re-run bf mandel tests (addressing #258).
* Preparation for Perl 7.
* Lua module conflicts have been resolved.
  • Loading branch information
nuald committed Jul 22, 2020
1 parent 5375c3b commit 10d5e4c
Show file tree
Hide file tree
Showing 20 changed files with 425 additions and 396 deletions.
30 changes: 30 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,33 @@ Style/RedundantRegexpCharacterClass:

Style/RedundantRegexpEscape:
Enabled: true

Lint/DuplicateElsifCondition:
Enabled: true

Style/AccessorGrouping:
Enabled: true

Style/ArrayCoercion:
Enabled: true

Style/BisectedAttrAccessor:
Enabled: true

Style/CaseLikeIf:
Enabled: true

Style/HashAsLastArrayItem:
Enabled: true

Style/HashLikeCase:
Enabled: true

Style/RedundantAssignment:
Enabled: true

Style/RedundantFetchBlock:
Enabled: true

Style/RedundantFileExtensionInRequire:
Enabled: true
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
docker_build = docker build docker/ -t benchmarks

.PHONY: build
build:
docker build docker/ -t benchmarks
$(docker_build)

.PHONY: rebuild
rebuild:
$(docker_build) --no-cache

docker_run = docker run -it --rm -v $(shell pwd):/src benchmarks

Expand Down
471 changes: 234 additions & 237 deletions README.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions base64/base64.rs/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion base64/base64.rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.0.1"
edition = "2018"

[dependencies]
base64 = "0.12.1"
base64 = "0.12.3"

[profile.release]
lto = true
8 changes: 5 additions & 3 deletions base64/test-xs.pl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use strict;
use v5.12;
use warnings;
use feature qw(signatures);
no warnings qw(experimental::signatures);

use MIME::Base64 qw(encode_base64 decode_base64);
use Time::HiRes 'time';
use Socket;
Expand All @@ -9,8 +12,7 @@

my $str = 'a' x STR_SIZE;

sub notify {
my $msg = shift;
sub notify ($msg) {
socket(my $socket, Socket::PF_INET, Socket::SOCK_STREAM, (getprotobyname('tcp'))[2]);
if (connect($socket, Socket::pack_sockaddr_in(9001, Socket::inet_aton('localhost')))) {
print $socket $msg;
Expand Down
8 changes: 5 additions & 3 deletions base64/test.pl
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use strict;
use v5.12;
use warnings;
use feature qw(signatures);
no warnings qw(experimental::signatures);

use MIME::Base64::Perl qw(encode_base64 decode_base64);
use Time::HiRes 'time';
use Socket;

sub notify {
my $msg = shift;
sub notify ($msg) {
socket(my $socket, Socket::PF_INET, Socket::SOCK_STREAM, (getprotobyname('tcp'))[2]);
if (connect($socket, Socket::pack_sockaddr_in(9001, Socket::inet_aton('localhost')))) {
print $socket $msg;
Expand Down
8 changes: 3 additions & 5 deletions base64/test.v
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ fn notify(msg string) {
sock := net.dial('127.0.0.1', 9001) or {
return
}
sock.write(msg) or {
}
sock.close() or {
}
sock.write(msg) or { }
sock.close() or { }
}

fn main() {
Expand All @@ -20,7 +18,7 @@ fn main() {
$if clang {
lang = 'V Clang'
}
notify('${lang}\t${C.getpid()}')
notify('$lang\t$C.getpid()')
mut bench := benchmark.new_benchmark()
bench.step()
mut s := 0
Expand Down
14 changes: 12 additions & 2 deletions brainfuck/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,20 @@ run[truby-native][bf.rb]:: run[truby-native][%]: % | $(rubocop)
run[jruby][bf.rb]:: run[jruby][%]: % | $(rubocop)
$(JRUBY_RUN) $(BF_SRC)

run[bf.lua]:: run[%]: %
.PHONY: lua-deps
lua-deps:
$(LUAROCKS_LUA) install luasocket
$(LUAROCKS_LUA) install luaposix

.PHONY: luajit-deps
luajit-deps:
$(LUAROCKS_LUAJIT) install luasocket
$(LUAROCKS_LUAJIT) install luaposix

run[bf.lua]:: run[%]: % | lua-deps
$(LUA_RUN) $(BF_SRC)

run[jit][bf.lua]:: run[jit][%]: %
run[jit][bf.lua]:: run[jit][%]: % | luajit-deps
$(LUA_JIT_RUN) $(BF_SRC)

run[bf.tcl]:: run[%]: %
Expand Down
43 changes: 12 additions & 31 deletions brainfuck/bf.pl
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
#! /usr/bin/env perl

use 5.10.1;
use strict;
use v5.12;
use warnings;
use feature qw(signatures);
no warnings qw(experimental);

use Socket;
no warnings 'experimental';

package Op;

sub new {
my $class = shift;
my $op = shift;
my $val = shift;

sub new ($class, $op, $val = undef) {
my $self = {
op => $op,
val => $val,
Expand All @@ -24,9 +21,7 @@ sub new {

package Tape;

sub new {
my $class = shift;

sub new ($class) {
my $self = {
tape => [0],
pos => 0,
Expand All @@ -35,23 +30,15 @@ sub new {
return $self;
}

sub get {
my $self = shift;

sub get ($self) {
return $self->{tape}[$self->{pos}];
}

sub inc {
my $self = shift;
my $x = shift;

sub inc ($self, $x) {
$self->{tape}[$self->{pos}] += $x;
}

sub move {
my $self = shift;
my $x = shift;

sub move ($self, $x) {
$self->{pos} += $x;
my $missing = $self->{pos} - @{$self->{tape}} + 1;
for (my $i = 0; $i < $missing; $i++) {
Expand All @@ -67,10 +54,7 @@ package Main;
my $PRINT = 3;
my $LOOP = 4;

sub parse {
my $source = shift;
my $i = shift || 0;

sub parse ($source, $i = 0) {
my $repr = [];
for (; $i < @{$source}; $i++) {
given ($source->[$i]) {
Expand All @@ -90,9 +74,7 @@ sub parse {
return ($repr, $i);
}

sub run {
my $parsed = shift;
my $tape = shift;
sub run ($parsed, $tape) {
foreach my $op (@$parsed) {
CORE::given ($op->{op}) {
when ($INC) { $tape->inc($op->{val}); }
Expand All @@ -107,8 +89,7 @@ sub run {
}
}

sub notify {
my $msg = shift;
sub notify ($msg) {
socket(my $socket, Socket::PF_INET, Socket::SOCK_STREAM, (getprotobyname('tcp'))[2]);
if (connect($socket, Socket::pack_sockaddr_in(9001, Socket::inet_aton('localhost')))) {
print $socket $msg;
Expand Down
10 changes: 4 additions & 6 deletions brainfuck/bf.v
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct Program {
}

fn new_program(code string) Program {
si := new_si(code)
mut si := new_si(code)
return Program{
ops: parse(mut si)
}
Expand Down Expand Up @@ -142,10 +142,8 @@ fn notify(msg string) {
sock := net.dial('127.0.0.1', 9001) or {
return
}
sock.write(msg) or {
}
sock.close() or {
}
sock.write(msg) or { }
sock.close() or { }
}

fn main() {
Expand All @@ -165,7 +163,7 @@ fn main() {
$if clang {
lang = 'V Clang'
}
notify('${lang}\t${C.getpid()}')
notify('$lang\t$C.getpid()')
new_program(code).run()
notify('stop')
}
7 changes: 5 additions & 2 deletions common/commands.mk
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,18 @@ ECHO_RUN = @tput bold; echo "$(MAKE) $@"; tput sgr0
XTIME := ../xtime.rb
CPANM := cpanm

LUAROCKS_LUA = PATH=$(PATH):/opt/luarocks/lua/bin luarocks
LUAROCKS_LUAJIT = PATH=$(PATH):/opt/luarocks/luajit/bin luarocks

CLOJURE_RUN = $(XTIME) clojure $(CLOJURE_FLAGS) $^
DOTNET_RUN = $(XTIME) dotnet $^
ELIXIR_RUN = $(XTIME) elixir $^
EXECUTABLE_RUN = $(XTIME) $^
JAVA_CLASS_RUN = $(XTIME) java -cp $(^D) $(basename $(^F))
JAVA_JAR_RUN = $(XTIME) java -jar $^
JRUBY_RUN = $(XTIME) jruby $^
LUA_JIT_RUN = $(XTIME) luajit $^
LUA_RUN = $(XTIME) lua5.3 $^
LUA_JIT_RUN = $(shell $(LUAROCKS_LUAJIT) path) && $(XTIME) luajit $^
LUA_RUN = $(shell $(LUAROCKS_LUA) path) && $(XTIME) lua $^
MONO_RUN = $(XTIME) mono -O=all --gc=sgen $^
NODE_RUN = $(XTIME) node $^
PERL_RUN = $(XTIME) perl $^
Expand Down

0 comments on commit 10d5e4c

Please sign in to comment.