File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,6 +5,21 @@ build: setup.py tsne/bh_sne.pyx \
55 $(wildcard tsne/bh_sne_src/*.cpp)
66 python $< build_ext --inplace
77
8+ PROFILE_LOCATION =$(shell pwd) /profile
9+
10+ $(PROFILE_LOCATION ) /bh_sne.profdata : PROFILE=generate
11+ $(PROFILE_LOCATION ) /bh_sne.profdata : setup.py Makefile tsne/bh_sne.pyx \
12+ $(wildcard tsne/bh_sne_src/*.h) \
13+ $(wildcard tsne/bh_sne_src/*.cpp)
14+ rm -rf build tsne/*.so *.so
15+ PROFILE=generate python $< build_ext --inplace
16+ mkdir -p $(PROFILE_LOCATION) && cd tsne/tests && LLVM_PROFILE_FILE="$(PROFILE_LOCATION)/%p-%m.profraw" py.test -s
17+ llvm-profdata merge -output=$@ $(PROFILE_LOCATION)/*.profraw
18+ rm -rf tsne/*.so *.so build tsne/*.o
19+
20+ build_pgo : setup.py $(PROFILE_LOCATION ) /bh_sne.profdata
21+ PROFILE=" $( PROFILE_LOCATION) /bh_sne.profdata" python $< build_ext --inplace
22+
823install : setup.py build
924 python $< install
1025
@@ -14,10 +29,10 @@ sdist: setup.py tsne/bh_sne.pyx \
1429 python $< sdist
1530
1631test : build
17- cd tsne/tests && py.test -s -vv
32+ cd tsne/tests && time py.test -s -vv
1833
1934clean :
2035 make -C tsne/bh_sne_src clean
21- rm -rf * .pyc * .so build/ bh_sne.cpp
36+ rm -rf * .pyc * .so build/ profile/ bh_sne.cpp
2237 rm -rf tsne/* .pyc tsne/* .so tsne/* .o tsne/build/ tsne/bh_sne.cpp
2338 rm -rf .pytest_cache/
Original file line number Diff line number Diff line change 4949else :
5050 # LINUX
5151 opt_flags = ['-msse3' , '-O3' , '-flto' ]
52+ if 'PROFILE' in os .environ :
53+ if os .environ ['PROFILE' ] == 'generate' :
54+ opt_flags .append ('-fprofile-instr-generate' )
55+ elif os .path .isfile (os .environ ['PROFILE' ]):
56+ opt_flags .append ('-fprofile-instr-use=' + os .environ ['PROFILE' ])
5257 ldflags = list (opt_flags )
5358 if 'LDFLAGS' in os .environ and os .environ ['LDFLAGS' ]:
5459 ldflags .extend (os .environ ['LDFLAGS' ].split (' ' ))
You can’t perform that action at this time.
0 commit comments