From d3b8b7ccd047504e00d12f0577ca37f0597254c2 Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Sun, 12 Feb 2012 10:22:36 +0100 Subject: [PATCH] Initial commit With more languages than just what was in the initial blog post. --- .gitignore | 22 ++++++++++++ Makefile | 80 +++++++++++++++++++++++++++++++++++++++++++ bash/null.bash | 3 ++ c/hello.c | 6 ++++ c/null.c | 3 ++ dash/null.dash | 3 ++ haskell/hello.hs | 1 + haskell/null.hs | 4 +++ lua/null.lua51 | 3 ++ lua/null.lua52 | 3 ++ lua/null.luajit | 3 ++ mksh/null.mksh | 3 ++ mksh/null.mksh-static | 3 ++ ocaml/null.ml | 1 + perl/null.pl | 3 ++ php/null.php | 5 +++ php/null.php-n | 5 +++ python/null.py | 5 +++ python/null.py-s | 5 +++ python/null.pypy | 5 +++ ruby/null.rb | 3 ++ tcl/null.tcl | 3 ++ 22 files changed, 172 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100755 bash/null.bash create mode 100644 c/hello.c create mode 100644 c/null.c create mode 100755 dash/null.dash create mode 100644 haskell/hello.hs create mode 100644 haskell/null.hs create mode 100755 lua/null.lua51 create mode 100755 lua/null.lua52 create mode 100755 lua/null.luajit create mode 100755 mksh/null.mksh create mode 100755 mksh/null.mksh-static create mode 100644 ocaml/null.ml create mode 100755 perl/null.pl create mode 100755 php/null.php create mode 100755 php/null.php-n create mode 100755 python/null.py create mode 100755 python/null.py-s create mode 100755 python/null.pypy create mode 100755 ruby/null.rb create mode 100755 tcl/null.tcl diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ab9dcb4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): + +*.[oa] +*.cm[ixo] +*.hi +*~ + +/log + +/c/c++-dynamic-null +/c/c++-static-null +/c/c-diet-dynamic-null +/c/c-diet-static-null +/c/c-libc-dynamic-null +/c/c-libc-static-null +/haskell/null-single +/haskell/null-threaded +/ocaml/null-byte +/ocaml/null-opt diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..de21874 --- /dev/null +++ b/Makefile @@ -0,0 +1,80 @@ +PROGS = \ + c/c-diet-static-null c/c-diet-dynamic-null \ + c/c-libc-static-null c/c-libc-dynamic-null \ + c/c++-static-null c/c++-dynamic-null \ + haskell/null-single haskell/null-threaded \ + ocaml/null-byte ocaml/null-opt + +SCRIPTS = \ + dash/null.dash bash/null.bash \ + lua/null.lua51 lua/null.lua52 lua/null.luajit \ + perl/null.pl ruby/null.rb \ + php/null.php php/null.php-n \ + tcl/null.tcl \ + python/null.py-s python/null.py python/null.pypy + +METRICS = \ + cycles,instructions,branches,branch-misses \ + dtlb-loads,dtlb-load-misses,itlb-loads,itlb-load-misses \ + cycles,instructions,cache-references,cache-misses \ + cycles,instructions,stalled-cycles-frontend,stalled-cycles-backend + +all: $(PROGS) + +$(PROGS): Makefile + +c-diet-static-%: %.c + diet gcc -static -O2 -Wall -o $@ $< + strip $@ + +c-diet-dynamic-%: %.c + diet gcc -O2 -Wall -o $@ $< + strip $@ + +c-libc-static-%: %.c + gcc -static -O2 -Wall -o $@ $< + strip $@ + +c-libc-dynamic-%: %.c + gcc -O2 -Wall -o $@ $< + strip $@ + +c++-static-%: %.c + g++ -static -O2 -Wall -o $@ $< + strip $@ + +c++-dynamic-%: %.c + g++ -O2 -Wall -o $@ $< + strip $@ + +haskell/null-single: haskell/null.hs + ghc --make -O2 -Wall -o $@ $< + strip $@ + +haskell/null-threaded: haskell/null.hs + ghc --make -O2 -Wall -threaded -o $@ $< + strip $@ + +ocaml/null-byte: ocaml/null.ml + ocamlc -o $@ $< + # no stripping as this is not an elf file + +ocaml/null-opt: ocaml/null.ml + ocamlopt -o $@ $< + strip $@ + +log: $(PROGS) $(SCRIPTS) Makefile + set -x; \ + rm -f log; \ + for prog in $(PROGS) $(SCRIPTS); do \ + for metric in $(METRICS); do \ + LC_ALL=C perf stat -e "$$metric" -r100 -o log --append ./$$prog; \ + done; \ + done + +.PHONY: log + +clean: + cd haskell && rm -f *.hi *.o + cd ocaml && rm -f *.cmo *.cmi *.cmx *.o + rm -f $(PROGS) diff --git a/bash/null.bash b/bash/null.bash new file mode 100755 index 0000000..cd11349 --- /dev/null +++ b/bash/null.bash @@ -0,0 +1,3 @@ +#!/bin/bash + +exit 0 \ No newline at end of file diff --git a/c/hello.c b/c/hello.c new file mode 100644 index 0000000..aed773b --- /dev/null +++ b/c/hello.c @@ -0,0 +1,6 @@ +#include + +int main() { + printf("Hello, world!\n"); + return 0; +} diff --git a/c/null.c b/c/null.c new file mode 100644 index 0000000..4cce7f6 --- /dev/null +++ b/c/null.c @@ -0,0 +1,3 @@ +int main() { + return 0; +} diff --git a/dash/null.dash b/dash/null.dash new file mode 100755 index 0000000..6d97b1d --- /dev/null +++ b/dash/null.dash @@ -0,0 +1,3 @@ +#!/bin/dash + +exit 0 \ No newline at end of file diff --git a/haskell/hello.hs b/haskell/hello.hs new file mode 100644 index 0000000..0872ac9 --- /dev/null +++ b/haskell/hello.hs @@ -0,0 +1 @@ +main = putStrLn "Hello, world!" diff --git a/haskell/null.hs b/haskell/null.hs new file mode 100644 index 0000000..ed8a561 --- /dev/null +++ b/haskell/null.hs @@ -0,0 +1,4 @@ +import System.Exit + +main :: IO () +main = exitWith ExitSuccess \ No newline at end of file diff --git a/lua/null.lua51 b/lua/null.lua51 new file mode 100755 index 0000000..f4adad3 --- /dev/null +++ b/lua/null.lua51 @@ -0,0 +1,3 @@ +#!/usr/bin/lua5.1 + +os.exit(0) \ No newline at end of file diff --git a/lua/null.lua52 b/lua/null.lua52 new file mode 100755 index 0000000..58b0872 --- /dev/null +++ b/lua/null.lua52 @@ -0,0 +1,3 @@ +#!/usr/bin/lua5.2 + +os.exit(0) \ No newline at end of file diff --git a/lua/null.luajit b/lua/null.luajit new file mode 100755 index 0000000..9536b3e --- /dev/null +++ b/lua/null.luajit @@ -0,0 +1,3 @@ +#!/usr/bin/luajit-2.0.0-beta9 + +os.exit(0) \ No newline at end of file diff --git a/mksh/null.mksh b/mksh/null.mksh new file mode 100755 index 0000000..60ffdf3 --- /dev/null +++ b/mksh/null.mksh @@ -0,0 +1,3 @@ +#!/bin/mksh + +exit 0 \ No newline at end of file diff --git a/mksh/null.mksh-static b/mksh/null.mksh-static new file mode 100755 index 0000000..3c2527a --- /dev/null +++ b/mksh/null.mksh-static @@ -0,0 +1,3 @@ +#!/bin/mksh-static + +exit 0 \ No newline at end of file diff --git a/ocaml/null.ml b/ocaml/null.ml new file mode 100644 index 0000000..91644e8 --- /dev/null +++ b/ocaml/null.ml @@ -0,0 +1 @@ +exit 0;; \ No newline at end of file diff --git a/perl/null.pl b/perl/null.pl new file mode 100755 index 0000000..89a517b --- /dev/null +++ b/perl/null.pl @@ -0,0 +1,3 @@ +#!/usr/bin/perl + +exit 0; diff --git a/php/null.php b/php/null.php new file mode 100755 index 0000000..5c61bf1 --- /dev/null +++ b/php/null.php @@ -0,0 +1,5 @@ +#!/usr/bin/php + + diff --git a/php/null.php-n b/php/null.php-n new file mode 100755 index 0000000..75ae991 --- /dev/null +++ b/php/null.php-n @@ -0,0 +1,5 @@ +#!/usr/bin/php -n + + diff --git a/python/null.py b/python/null.py new file mode 100755 index 0000000..1fda76c --- /dev/null +++ b/python/null.py @@ -0,0 +1,5 @@ +#!/usr/bin/python + +import sys + +sys.exit(0) diff --git a/python/null.py-s b/python/null.py-s new file mode 100755 index 0000000..c280a36 --- /dev/null +++ b/python/null.py-s @@ -0,0 +1,5 @@ +#!/usr/bin/python -S + +import sys + +sys.exit(0) diff --git a/python/null.pypy b/python/null.pypy new file mode 100755 index 0000000..6f3f52b --- /dev/null +++ b/python/null.pypy @@ -0,0 +1,5 @@ +#!/usr/bin/pypy + +import sys + +sys.exit(0) diff --git a/ruby/null.rb b/ruby/null.rb new file mode 100755 index 0000000..2daa47a --- /dev/null +++ b/ruby/null.rb @@ -0,0 +1,3 @@ +#!/usr/bin/ruby + +exit(0) diff --git a/tcl/null.tcl b/tcl/null.tcl new file mode 100755 index 0000000..98852e3 --- /dev/null +++ b/tcl/null.tcl @@ -0,0 +1,3 @@ +#!/usr/bin/tclsh + +exit 0 \ No newline at end of file -- 2.39.2