]> git.k1024.org Git - pyxattr.git/blob - Makefile
Add a mini-benchmark suite
[pyxattr.git] / Makefile
1 SPHINXOPTS    = -W
2 SPHINXBUILD   = sphinx-build
3 DOCDIR        = doc
4 DOCHTML       = $(DOCDIR)/html
5 DOCTREES      = $(DOCDIR)/doctrees
6 ALLSPHINXOPTS = -d $(DOCTREES) $(SPHINXOPTS) $(DOCDIR)
7
8 MODNAME = xattr.so
9 RSTFILES = doc/index.rst doc/module.rst NEWS README.rst doc/conf.py
10
11 all: doc test
12
13 $(MODNAME): xattr.c
14         ./setup.py build_ext --inplace
15
16 $(DOCHTML)/index.html: $(MODNAME) $(RSTFILES)
17         $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(DOCHTML)
18         touch $@
19
20 doc: $(DOCHTML)/index.html
21
22 dist:
23         fakeroot ./setup.py sdist
24
25 test:
26         @for ver in 2.4 2.5 2.6 2.7 3.0 3.1 3.2 3.3 3.4 3.5; do \
27           for flavour in "" "-dbg"; do \
28             if type python$$ver$$flavour >/dev/null; then \
29               echo Testing with python$$ver$$flavour; \
30               python$$ver$$flavour ./setup.py test -q; \
31             fi; \
32           done; \
33         done;
34         @if type pypy >/dev/null; then \
35           echo Testing with pypy; \
36           pypy ./setup.py test -q; \
37         fi
38
39 benchmark: $(MODNAME)
40         @set -e; \
41         TESTFILE=`mktemp`;\
42         trap 'rm $$TESTFILE' EXIT; \
43         for ver in 2.4 2.5 2.6 2.7 3.0 3.1 3.2 3.3 3.4 3.5; do \
44             if type python$$ver >/dev/null; then \
45               echo Benchmarking with python$$ver; \
46               python$$ver ./setup.py build -q; \
47               echo "  - set (with override)"; \
48               python$$ver -m timeit -s 'import xattr' "xattr.set('$$TESTFILE', 'user.comment', 'hello')"; \
49               echo "  - list"; \
50               python$$ver -m timeit -s 'import xattr' "xattr.list('$$TESTFILE')"; \
51               echo "  - get"; \
52               python$$ver -m timeit -s 'import xattr' "xattr.get('$$TESTFILE', 'user.comment')"; \
53               echo "  - set + remove"; \
54               python$$ver -m timeit -s 'import xattr' "xattr.set('$$TESTFILE', 'user.comment', 'hello'); xattr.remove('$$TESTFILE', 'user.comment')"; \
55             fi; \
56         done;
57
58 coverage:
59         $(MAKE) clean
60         $(MAKE) test CFLAGS="-coverage"
61         lcov --capture --directory . --output-file coverage.info
62         genhtml coverage.info --output-directory out
63
64 clean:
65         rm -rf $(DOCHTML) $(DOCTREES)
66         rm -f $(MODNAME)
67         rm -f *.so
68         rm -rf build
69
70 .PHONY: doc test clean dist coverage