From 9765589d6c3ea0df47b0871e02f7205bf8136d80 Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Tue, 24 Jul 2018 22:17:02 +0200 Subject: [PATCH] Add a mini-benchmark suite This will make it easy to see the impact of changes, for example the one proposed in #16. --- Makefile | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Makefile b/Makefile index 905791d..62c035d 100644 --- a/Makefile +++ b/Makefile @@ -36,6 +36,25 @@ test: pypy ./setup.py test -q; \ fi +benchmark: $(MODNAME) + @set -e; \ + TESTFILE=`mktemp`;\ + trap 'rm $$TESTFILE' EXIT; \ + for ver in 2.4 2.5 2.6 2.7 3.0 3.1 3.2 3.3 3.4 3.5; do \ + if type python$$ver >/dev/null; then \ + echo Benchmarking with python$$ver; \ + python$$ver ./setup.py build -q; \ + echo " - set (with override)"; \ + python$$ver -m timeit -s 'import xattr' "xattr.set('$$TESTFILE', 'user.comment', 'hello')"; \ + echo " - list"; \ + python$$ver -m timeit -s 'import xattr' "xattr.list('$$TESTFILE')"; \ + echo " - get"; \ + python$$ver -m timeit -s 'import xattr' "xattr.get('$$TESTFILE', 'user.comment')"; \ + echo " - set + remove"; \ + python$$ver -m timeit -s 'import xattr' "xattr.set('$$TESTFILE', 'user.comment', 'hello'); xattr.remove('$$TESTFILE', 'user.comment')"; \ + fi; \ + done; + coverage: $(MAKE) clean $(MAKE) test CFLAGS="-coverage" -- 2.39.5