This adds the outline of a benchmark suite to bitstring.
authorRichard W.M. Jones <rich@annexia.org>
Tue, 26 Aug 2008 08:13:48 +0000 (08:13 +0000)
committerRichard W.M. Jones <rich@annexia.org>
Tue, 26 Aug 2008 08:13:48 +0000 (08:13 +0000)
Makefile.in
configure.ac

index fba131c..808146d 100644 (file)
@@ -24,6 +24,8 @@ OCAMLFIND     = @OCAMLFIND@
 OCAMLMKLIB     = @OCAMLMKLIB@
 OCAMLDOC       = @OCAMLDOC@
 INSTALL                = @INSTALL@
 OCAMLMKLIB     = @OCAMLMKLIB@
 OCAMLDOC       = @OCAMLDOC@
 INSTALL                = @INSTALL@
+TIME           = @TIME@
+GPROF          = @GPROF@
 
 pkg_cil                = @pkg_cil@
 pkg_extlib     = @pkg_extlib@
 
 pkg_cil                = @pkg_cil@
 pkg_extlib     = @pkg_extlib@
@@ -46,6 +48,8 @@ EXAMPLES      = $(patsubst %.ml,%,$(wildcard examples/*.ml))
 
 TESTS          = $(patsubst %.ml,%,$(wildcard tests/*.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 \
 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
 
          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)
 # 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
        @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 \
        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
 
 .SUFFIXES:      .cmo .cmi .cmx .ml .mli .mll
index 36b6d26..8c93229 100644 (file)
@@ -46,7 +46,7 @@ if test "x$OCAMLFIND" = "x"; then
 fi
 
 dnl Check for camlp4
 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
 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)
 
 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])
 dnl Produce output files.
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_FILES([Makefile META bitstring_config.ml cil-tools/Makefile])