Sfoglia il codice sorgente

Script and make targets for profiling

Matthew Wang 11 anni fa
parent
commit
98b49e3de8
3 ha cambiato i file con 35 aggiunte e 2 eliminazioni
  1. 1
    0
      .gitignore
  2. 10
    2
      Makefile
  3. 24
    0
      tests/profile.sh

+ 1
- 0
.gitignore Vedi File

@@ -1,5 +1,6 @@
1 1
 *.pyc
2 2
 *~
3
+*.tmp
3 4
 /MANIFEST
4 5
 /build/
5 6
 /cdiff.egg-info/

+ 10
- 2
Makefile Vedi File

@@ -2,8 +2,10 @@
2 2
 
3 3
 TESTPYPI = https://testpypi.python.org/pypi
4 4
 PYPI = https://pypi.python.org/pypi
5
+LONG_PATCH_CMD = for i in {1..100}; do cat tests/svn/in.diff; done
6
+PROFILE_ARGS = -m cProfile -s time cdiff.py -c always -s -w 60
5 7
 
6
-.PHONY: dogfood test test3 clean build dist-test dist
8
+.PHONY: dogfood test test3 profile profile3 clean build dist-test dist
7 9
 
8 10
 dogfood:
9 11
 	./cdiff.py
@@ -15,8 +17,14 @@ test:
15 17
 test3:
16 18
 	PYTHON=python3 tests/regression.sh
17 19
 
20
+profile:
21
+	tests/profile.sh profile.tmp
22
+
23
+profile3:
24
+	tests/profile.sh profile3.tmp
25
+
18 26
 clean:
19
-	rm -f MANIFEST
27
+	rm -f MANIFEST profile*.tmp*
20 28
 	rm -rf build/ cdiff.egg-info/ dist/ __pycache__/
21 29
 
22 30
 build:

+ 24
- 0
tests/profile.sh Vedi File

@@ -0,0 +1,24 @@
1
+#!/bin/bash
2
+
3
+OUTPUT=${1:?"output file required"}
4
+
5
+SELF_DIR=$(cd $(dirname $0) && pwd) || exit 1
6
+CDIFF_PY=$SELF_DIR/../cdiff.py
7
+
8
+# To test with py3k: PYTHON=python3 make test
9
+PYTHON=${PYTHON:-python}
10
+
11
+set -o errexit
12
+STATS="stats.$$.tmp"
13
+
14
+for i in {1..100}; do cat "tests/svn/in.diff"; done \
15
+    | $PYTHON -m cProfile -o $STATS $CDIFF_PY -c always -s -w 60 \
16
+    > /dev/null
17
+
18
+$PYTHON -c "import pstats;  p = pstats.Stats('$STATS'); \
19
+    p.strip_dirs().sort_stats('time').print_stats('cdiff')" \
20
+    | tee $OUTPUT
21
+
22
+rm -f $STATS
23
+
24
+# vim:set et sts=4 sw=4: