aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-04-23 22:42:36 -0500
committerJoel Martin <github@martintribe.org>2014-04-23 22:42:36 -0500
commit1f2651c54ee30039b6a1289a63e44d538ecf6d6a (patch)
treeb0164f0e644ba82b76ff59fcabea81152f08e556
parente6a1697802135bf29a1ed50074d9244653235e4b (diff)
downloadmal-1f2651c54ee30039b6a1289a63e44d538ecf6d6a.tar.gz
mal-1f2651c54ee30039b6a1289a63e44d538ecf6d6a.zip
Perl: add Makefile and time-ms for perf tests.
-rw-r--r--perl/Makefile21
-rw-r--r--perl/core.pm2
2 files changed, 23 insertions, 0 deletions
diff --git a/perl/Makefile b/perl/Makefile
new file mode 100644
index 0000000..772bba7
--- /dev/null
+++ b/perl/Makefile
@@ -0,0 +1,21 @@
+TESTS =
+
+SOURCES_BASE = readline.pm types.pm reader.pm printer.pm \
+ interop.pm
+SOURCES_LISP = env.pm core.pm stepA_more.pl
+SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
+
+#all: mal.pl
+
+.PHONY: stats tests $(TESTS)
+
+stats: $(SOURCES)
+ @wc $^
+stats-lisp: $(SOURCES_LISP)
+ @wc $^
+
+tests: $(TESTS)
+
+$(TESTS):
+ @echo "Running $@"; \
+ ruby $@ || exit 1; \
diff --git a/perl/core.pm b/perl/core.pm
index 1e1a9ff..eeee77e 100644
--- a/perl/core.pm
+++ b/perl/core.pm
@@ -3,6 +3,7 @@ use strict;
use warnings FATAL => qw(all);
use Exporter 'import';
our @EXPORT_OK = qw($core_ns);
+use Time::HiRes qw(time);
use readline;
use types qw(_sequential_Q _equal_Q _clone $nil $true $false
@@ -183,6 +184,7 @@ our $core_ns = {
'-' => sub { Integer->new(${$_[0]->nth(0)} - ${$_[0]->nth(1)}) },
'*' => sub { Integer->new(${$_[0]->nth(0)} * ${$_[0]->nth(1)}) },
'/' => sub { Integer->new(${$_[0]->nth(0)} / ${$_[0]->nth(1)}) },
+ 'time-ms' => sub { Integer->new(int(time()*1000)) },
'list' => sub { List->new($_[0]->{val}) },
'list?' => sub { _list_Q($_[0]->nth(0)) ? $true : $false },