From 56d0e8f9f08d7b9247f761cf4894aad36c8bf304 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 26 Aug 2008 08:13:48 +0000 Subject: [PATCH] This adds the outline of a benchmark suite to bitstring. --- Makefile.in | 38 +++++++++++++++++++++++++++++++++++++- configure.ac | 8 +++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/Makefile.in b/Makefile.in index fba131c..808146d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -24,6 +24,8 @@ OCAMLFIND = @OCAMLFIND@ OCAMLMKLIB = @OCAMLMKLIB@ OCAMLDOC = @OCAMLDOC@ INSTALL = @INSTALL@ +TIME = @TIME@ +GPROF = @GPROF@ pkg_cil = @pkg_cil@ pkg_extlib = @pkg_extlib@ @@ -46,6 +48,8 @@ EXAMPLES = $(patsubst %.ml,%,$(wildcard examples/*.ml)) TESTS = $(patsubst %.ml,%,$(wildcard tests/*.ml)) +BENCHMARKS = $(patsubst %.ml,%,$(wildcard benchmarks/*.ml)) + all: bitstring.cma bitstring_persistent.cma \ bitstring.cmxa bitstring_persistent.cmxa \ pa_bitstring.cmo \ @@ -143,12 +147,44 @@ print-examples: pa_bitstring.cmo if [ $$? -ne 0 ]; then exit 1; fi; \ done +# Benchmarks. + +ifneq ($(TIME),no) + +benchmarks: pa_bitstring.cmo bitstring.cma bitstring_persistent.cma + @for f in $(BENCHMARKS); do \ + $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(PP) \ + -package unix -linkpkg -I . bitstring.cmxa $$f.ml -o $$f.opt; \ + if [ $$? -ne 0 ]; then exit 1; fi; \ + $(TIME) -f "$$f: %e seconds" $$f.opt; \ + if [ $$? -ne 0 ]; then exit 1; fi; \ + done +ifneq ($(GPROF),no) + @for f in $(BENCHMARKS); do \ + $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(PP) -p \ + -package unix -linkpkg -I . bitstring.cmxa $$f.ml -o $$f.opt.p; \ + if [ $$? -ne 0 ]; then exit 1; fi; \ + rm -f gmon.out; \ + $$f.opt.p; \ + if [ $$? -ne 0 ]; then exit 1; fi; \ + gprof $$f.opt.p > $$f.profile; \ + if [ $$? -ne 0 ]; then exit 1; fi; \ + echo "Wrote profile of $$f"; \ + echo " to $$f.profile"; \ + rm -f gmon.out; \ + done +endif + +endif + # Clean. clean: rm -f core *~ *.cmi *.cmo *.cmx *.cma *.cmxa *.a *.o rm -f tests/*~ tests/*.cmi tests/*.cmo $(TESTS) rm -f examples/*~ examples/*.cmi examples/*.cmo $(EXAMPLES) + rm -f benchmarks/*~ benchmarks/*.cmi benchmarks/*.cmo + rm -f benchmarks/*.opt benchmarks/*.opt.p benchmarks/*.profile @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done distclean: clean @@ -227,6 +263,6 @@ check-manifest: exit $$rv .PHONY: depend dist check-manifest dpkg doc \ - print-examples print-tests examples test + print-examples print-tests examples test benchmarks .SUFFIXES: .cmo .cmi .cmx .ml .mli .mll diff --git a/configure.ac b/configure.ac index 36b6d26..8c93229 100644 --- a/configure.ac +++ b/configure.ac @@ -46,7 +46,7 @@ if test "x$OCAMLFIND" = "x"; then fi dnl Check for camlp4 -AC_CHECK_PROG(CAMLP4OF,camlp4of.opt,camlp4of.opt) +AC_CHECK_PROG(CAMLP4OF,camlp4of.opt,camlp4of.opt,no) if test "x$CAMLP4OF" = "xno"; then AC_MSG_ERROR([You must have camlp4 installed]) fi @@ -59,6 +59,12 @@ dnl Check for CIL (optional) AC_CHECK_OCAML_PKG(cil) AC_SUBST(pkg_cil) +dnl Check for /usr/bin/time and get full path. +AC_PATH_PROG(TIME,time,no) + +dnl Check for gprof. +AC_CHECK_PROG(GPROF,gprof,gprof,no) + dnl Produce output files. AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([Makefile META bitstring_config.ml cil-tools/Makefile]) -- 1.8.3.1