tools: update profiling rules
A bunch of cleanups to make profiling possible again, and easier. "make quickprof-CMD" generates a profile for CMD, which must be one word and runs against one of the sample journals (the usual quickprof-"SOME WORDS" quoting trick isn't working here for some reason) Also, "make hledgerprof" builds the hledgerprof executable (in stack's bin dir) for profiling. "make hledgercov" builds the hledgercov executable (in ./bin) for coverage reports (renamed from hledgerhpc to remind me that HPC is nothing to do with heap coverage)
This commit is contained in:
		
							parent
							
								
									9da0ab6af9
								
							
						
					
					
						commit
						523ab4331a
					
				
							
								
								
									
										140
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										140
									
								
								Makefile
									
									
									
									
									
								
							| @ -48,11 +48,11 @@ help2: \ | |||||||
| # will die on encountering non-ascii data. Set LANG to something if not already set.
 | # will die on encountering non-ascii data. Set LANG to something if not already set.
 | ||||||
| export LANG?=en_US.UTF-8 | export LANG?=en_US.UTF-8 | ||||||
| 
 | 
 | ||||||
| # # command to run during "make prof" and "make heap"
 | # command to run during profiling (time and heap)
 | ||||||
| # PROFCMD=bin/hledger-prof balance -f data/1000x1000x10.journal >/dev/null
 | #PROFCMD=stack exec -- hledgerprof balance -f data/1000x1000x10.journal >/dev/null
 | ||||||
| 
 | 
 | ||||||
| # #PROFRTSFLAGS=-p
 | #PROFRTSFLAGS=-p
 | ||||||
| # PROFRTSFLAGS=-P
 | PROFRTSFLAGS=-P | ||||||
| 
 | 
 | ||||||
| # # command to run during "make coverage"
 | # # command to run during "make coverage"
 | ||||||
| # COVCMD=test
 | # COVCMD=test
 | ||||||
| @ -202,7 +202,6 @@ BUILDFLAGS:=$(BUILDFLAGS1) -DVERSION='"$(VERSION)dev"' | |||||||
| 
 | 
 | ||||||
| # TIME:=$(shell date +"%Y%m%d%H%M")
 | # TIME:=$(shell date +"%Y%m%d%H%M")
 | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| ###############################################################################
 | ###############################################################################
 | ||||||
| $(call def-help-subsection,INSTALLING:) | $(call def-help-subsection,INSTALLING:) | ||||||
| 
 | 
 | ||||||
| @ -300,12 +299,12 @@ build: \ | |||||||
| # 	@/usr/bin/env which sp >/dev/null || \
 | # 	@/usr/bin/env which sp >/dev/null || \
 | ||||||
| # 	  (echo '"sp" is required for auto-compilation. darcs get http://joyful.com/darcsden/simon/searchpath, make it (cabal install-ing any needed packages) and add it to your PATH'; exit 1)
 | # 	  (echo '"sp" is required for auto-compilation. darcs get http://joyful.com/darcsden/simon/searchpath, make it (cabal install-ing any needed packages) and add it to your PATH'; exit 1)
 | ||||||
| 
 | 
 | ||||||
| # # force a compile even if binary exists, since we don't specify dependencies for these
 | # force a compile even if binary exists, since we don't specify dependencies for these
 | ||||||
| # .PHONY: bin/hledgerdev bin/hledger-prof bin/hledgeropt bin/hledger-webdev
 | .PHONY: bin/hledgerdev bin/hledgerprof # bin/hledger-webdev
 | ||||||
| 
 | 
 | ||||||
| # NB requires cabal macros generated by cabal build in hledger/
 | # NB requires cabal macros generated by cabal build in hledger/
 | ||||||
| bin/hledgerdev hledgerdev: \ | bin/hledgerdev hledgerdev: \ | ||||||
| 	$(call def-help,hledgerdev, quickly build the hledger executable (with ghc and -DDEVELOPMENT) ) | 	$(call def-help,hledgerdev, build an unoptimised "bin/hledgerdev" executable quickly (with ghc) ) | ||||||
| 	$(GHC) $(MAIN) -o bin/hledgerdev $(BUILDFLAGS) | 	$(GHC) $(MAIN) -o bin/hledgerdev $(BUILDFLAGS) | ||||||
| 
 | 
 | ||||||
| # bin/hledgerdev.ghc-%: $(SOURCEFILES) \
 | # bin/hledgerdev.ghc-%: $(SOURCEFILES) \
 | ||||||
| @ -323,9 +322,32 @@ bin/hledgerdev hledgerdev: \ | |||||||
| # 	build hledger with the main supported GHC versions\
 | # 	build hledger with the main supported GHC versions\
 | ||||||
| # 	)
 | # 	)
 | ||||||
| 
 | 
 | ||||||
|  | hledgerprof: \ | ||||||
|  | 	$(call def-help,hledgerprof, build "hledgerprof" for profiling (with stack) ) | ||||||
|  | 	stack build hledger-lib hledger --library-profiling --executable-profiling --ghc-options=-fprof-auto | ||||||
|  | 	cp `stack exec which hledger`{,prof} | ||||||
|  | 	@echo to profile, use stack exec -- hledgerprof ... | ||||||
|  | 
 | ||||||
|  | # bin/hledgerprof: \
 | ||||||
|  | # 	$(call def-help,bin/hledgerprof,\
 | ||||||
|  | # 	build the "production" cabal build with profiling enabled.\
 | ||||||
|  | # 	)
 | ||||||
|  | # 	rm -f bin/hledgerprof
 | ||||||
|  | # 	cabal install --enable-profiling --ghc-options=-fprof-auto ./hledger-lib ./hledger \
 | ||||||
|  | # 		&& mv  $(CABALINSTALLDIR)/bin/hledger bin/hledgerprof
 | ||||||
|  | 
 | ||||||
|  | # # build the dev build with profiling enabled.
 | ||||||
|  | # # not working with cabal sandbox
 | ||||||
|  | # # bin/hledgerdev-prof:
 | ||||||
|  | # # 	$(GHC) $(BUILDFLAGS) $(PROFBUILDFLAGS) $(MAIN) -o $@
 | ||||||
|  | 
 | ||||||
|  | hledgercov: \ | ||||||
|  | 	$(call def-help,hledgercov, build "bin/hledgercov" for coverage reports (with ghc) ) | ||||||
|  | 	$(GHC) $(MAIN) -fhpc -o bin/hledgercov -outputdir .hledgercovobjs $(BUILDFLAGS) | ||||||
|  | 
 | ||||||
| #	hledger-lib/Hledger/Read/TimelogReaderPP.hs
 | #	hledger-lib/Hledger/Read/TimelogReaderPP.hs
 | ||||||
| dev: dev.hs $(SOURCEFILES) \ | dev: dev.hs $(SOURCEFILES) \ | ||||||
| 	$(call def-help,dev,build the dev.hs script (for quick experiments/benchmarks)) | 	$(call def-help,dev, build the dev.hs script for quick experiments (with ghc) ) | ||||||
| 	stack ghc -- $(CABALMACROSFLAGS) -ihledger-lib dev.hs \
 | 	stack ghc -- $(CABALMACROSFLAGS) -ihledger-lib dev.hs \
 | ||||||
| 
 | 
 | ||||||
| dev-profile: $(SOURCEFILES) \ | dev-profile: $(SOURCEFILES) \ | ||||||
| @ -335,36 +357,6 @@ dev-profile: $(SOURCEFILES) \ | |||||||
| 	&& cp dev.prof dev.prof.$(TIME) \
 | 	&& cp dev.prof dev.prof.$(TIME) \
 | ||||||
| 	&& profiteur dev.prof | 	&& profiteur dev.prof | ||||||
| 
 | 
 | ||||||
| # #CABALINSTALLDIR=~/.cabal
 |  | ||||||
| # CABALINSTALLDIR=.cabal-sandbox
 |  | ||||||
| # bin/hledger: \
 |  | ||||||
| # 	$(call def-help,bin/hledger,\
 |  | ||||||
| # 	build the "production" optimised cabal build with profiling enabled.\
 |  | ||||||
| # 	)
 |  | ||||||
| # 	rm -f bin/hledger
 |  | ||||||
| # 	cabal install --disable-profiling ./hledger-lib ./hledger \
 |  | ||||||
| # 		&& mv $(CABALINSTALLDIR)/bin/hledger bin/hledger
 |  | ||||||
| 
 |  | ||||||
| # bin/hledger-prof: \
 |  | ||||||
| # 	$(call def-help,bin/hledger-prof,\
 |  | ||||||
| # 	build the "production" cabal build with profiling enabled.\
 |  | ||||||
| # 	)
 |  | ||||||
| # 	rm -f bin/hledger-prof
 |  | ||||||
| # 	cabal install --enable-profiling --ghc-options=-fprof-auto ./hledger-lib ./hledger \
 |  | ||||||
| # 		&& mv  $(CABALINSTALLDIR)/bin/hledger bin/hledger-prof
 |  | ||||||
| 
 |  | ||||||
| # # build the dev build with profiling enabled.
 |  | ||||||
| # # not working with cabal sandbox
 |  | ||||||
| # # bin/hledgerdev-prof:
 |  | ||||||
| # # 	$(GHC) $(BUILDFLAGS) $(PROFBUILDFLAGS) $(MAIN) -o $@
 |  | ||||||
| 
 |  | ||||||
| # hledgerhpc: \
 |  | ||||||
| # 	$(call def-help,hledgerhpc,\
 |  | ||||||
| # 	build the heap profiling binary for coverage reports and heap profiles.\
 |  | ||||||
| # 	Keep these .o files separate from the regular ones.\
 |  | ||||||
| # 	)
 |  | ||||||
| # 	$(GHC) $(MAIN) -fhpc -o bin/hledgerhpc -outputdir .hledgerhpcobjs $(BUILDFLAGS)
 |  | ||||||
| 
 |  | ||||||
| # # build other executables quickly
 | # # build other executables quickly
 | ||||||
| 
 | 
 | ||||||
| # bin/hledger-webdev: link-web-dirs \
 | # bin/hledger-webdev: link-web-dirs \
 | ||||||
| @ -694,10 +686,10 @@ cabalfiletest: \ | |||||||
| # prof: samplejournals \
 | # prof: samplejournals \
 | ||||||
| # 	$(call def-help,prof,\
 | # 	$(call def-help,prof,\
 | ||||||
| # 	generate and archive an execution profile\
 | # 	generate and archive an execution profile\
 | ||||||
| # 	) #bin/hledger-prof
 | # 	) #bin/hledgerprof
 | ||||||
| # 	@echo "Profiling: $(PROFCMD)"
 | # 	@echo "Profiling: $(PROFCMD)"
 | ||||||
| # 	-$(PROFCMD) +RTS $(PROFRTSFLAGS) -RTS
 | # 	-$(PROFCMD) +RTS $(PROFRTSFLAGS) -RTS
 | ||||||
| # 	mv hledger-prof.prof doc/profs/$(TIME).prof
 | # 	mv hledgerprof.prof doc/profs/$(TIME).prof
 | ||||||
| # 	(cd doc/profs; rm -f latest*.prof; ln -s $(TIME).prof latest.prof)
 | # 	(cd doc/profs; rm -f latest*.prof; ln -s $(TIME).prof latest.prof)
 | ||||||
| 
 | 
 | ||||||
| # viewprof: prof \
 | # viewprof: prof \
 | ||||||
| @ -706,21 +698,23 @@ cabalfiletest: \ | |||||||
| # 	)
 | # 	)
 | ||||||
| # 	tools/simplifyprof.hs doc/profs/latest.prof
 | # 	tools/simplifyprof.hs doc/profs/latest.prof
 | ||||||
| 
 | 
 | ||||||
| # quickprof: samplejournals \
 | quickprof-%: hledgerprof samplejournals \ | ||||||
| # 	$(call def-help,quickprof,\
 | 		$(call def-help,quickprof-"CMD", profile some command against a sample journal and display the execution profile ) | ||||||
| # 	generate and display an execution profile, dont save or simplify\
 | 	stack exec -- hledgerprof +RTS $(PROFRTSFLAGS) -RTS $* -f data/10000x1000x10.journal >/dev/null | ||||||
| # 	) #bin/hledger-prof
 | 	profiteur hledgerprof.prof | ||||||
| # 	@echo "Profiling: $(PROFCMD)"
 | 	@echo | ||||||
| # 	-$(PROFCMD) +RTS $(PROFRTSFLAGS) -RTS
 | 	@head -20 hledgerprof.prof | ||||||
| # 	echo; cat hledger-prof.prof
 | 	@echo ... | ||||||
|  | 	@echo | ||||||
|  | 	@echo see hledgerprof.prof or hledgerprof.prof.html for the full report | ||||||
| 
 | 
 | ||||||
| # heap: samplejournals \
 | # heap: samplejournals \
 | ||||||
| # 	$(call def-help,heap,\
 | # 	$(call def-help,heap,\
 | ||||||
| # 	generate and archive a graphical heap profile\
 | # 	generate and archive a graphical heap profile\
 | ||||||
| # 	) #bin/hledger-prof
 | # 	) #bin/hledgerprof
 | ||||||
| # 	@echo "Profiling heap with: $(PROFCMD)"
 | # 	@echo "Profiling heap with: $(PROFCMD)"
 | ||||||
| # 	$(PROFCMD) +RTS -hc -RTS
 | # 	$(PROFCMD) +RTS -hc -RTS
 | ||||||
| # 	mv hledger-prof.hp doc/profs/$(TIME).hp
 | # 	mv hledgerprof.hp doc/profs/$(TIME).hp
 | ||||||
| # 	(cd doc/profs; rm -f latest.hp; ln -s $(TIME).hp latest.hp; \
 | # 	(cd doc/profs; rm -f latest.hp; ln -s $(TIME).hp latest.hp; \
 | ||||||
| # 		hp2ps $(TIME).hp; rm -f latest.ps; ln -s $(TIME).ps latest.ps; rm -f *.aux)
 | # 		hp2ps $(TIME).hp; rm -f latest.ps; ln -s $(TIME).ps latest.ps; rm -f *.aux)
 | ||||||
| 
 | 
 | ||||||
| @ -733,25 +727,25 @@ cabalfiletest: \ | |||||||
| # quickheap: samplejournals \
 | # quickheap: samplejournals \
 | ||||||
| # 	$(call def-help,quickheap,\
 | # 	$(call def-help,quickheap,\
 | ||||||
| # 	generate and display a graphical heap profile, dont save\
 | # 	generate and display a graphical heap profile, dont save\
 | ||||||
| # 	) #bin/hledger-prof
 | # 	) #bin/hledgerprof
 | ||||||
| # 	@echo "Profiling heap with: $(PROFCMD)"
 | # 	@echo "Profiling heap with: $(PROFCMD)"
 | ||||||
| # 	$(PROFCMD) +RTS -hc -RTS
 | # 	$(PROFCMD) +RTS -hc -RTS
 | ||||||
| # 	hp2ps hledger-prof.hp
 | # 	hp2ps hledgerprof.hp
 | ||||||
| # 	$(VIEWPS) hledger.ps
 | # 	$(VIEWPS) hledger.ps
 | ||||||
| 
 | 
 | ||||||
| # quickcoverage: hledgerhpc \
 | # quickcoverage: hledgercov \
 | ||||||
| # 	$(call def-help,quickcoverage,\
 | # 	$(call def-help,quickcoverage,\
 | ||||||
| # 	display a code coverage text report from running hledger COVCMD\
 | # 	display a code coverage text report from running hledger COVCMD\
 | ||||||
| # 	)
 | # 	)
 | ||||||
| # 	@echo "Generating code coverage text report for hledger command: $(COVCMD)"
 | # 	@echo "Generating code coverage text report for hledger command: $(COVCMD)"
 | ||||||
| # 	tools/runhledgerhpc "report" $(COVCMD)
 | # 	tools/runhledgercov "report" $(COVCMD)
 | ||||||
| 
 | 
 | ||||||
| # coverage: samplejournals hledgerhpc \
 | # coverage: samplejournals hledgercov \
 | ||||||
| # 	$(call def-help,coverage,\
 | # 	$(call def-help,coverage,\
 | ||||||
| # 	generate a code coverage html report from running hledger COVCMD\
 | # 	generate a code coverage html report from running hledger COVCMD\
 | ||||||
| # 	)
 | # 	)
 | ||||||
| # 	@echo "Generating code coverage html report for hledger command: $(COVCMD)"
 | # 	@echo "Generating code coverage html report for hledger command: $(COVCMD)"
 | ||||||
| # 	tools/runhledgerhpc "markup --destdir=doc/profs/coverage" $(COVCMD)
 | # 	tools/runhledgercov "markup --destdir=doc/profs/coverage" $(COVCMD)
 | ||||||
| # 	cd doc/profs/coverage; rm -f index.html; ln -s hpc_index.html index.html
 | # 	cd doc/profs/coverage; rm -f index.html; ln -s hpc_index.html index.html
 | ||||||
| 
 | 
 | ||||||
| # viewcoverage: \
 | # viewcoverage: \
 | ||||||
| @ -781,31 +775,29 @@ ghci-web: \ | |||||||
| 		$(call def-help,ghci-web, start a GHCI REPL and load the hledger-lib, hledger and hledger-web packages) | 		$(call def-help,ghci-web, start a GHCI REPL and load the hledger-lib, hledger and hledger-web packages) | ||||||
| 	stack exec $(GHCI) -- $(BUILDFLAGS) hledger-web/app/main.hs | 	stack exec $(GHCI) -- $(BUILDFLAGS) hledger-web/app/main.hs | ||||||
| 
 | 
 | ||||||
| # samplejournals: data/sample.journal data/100x100x10.journal data/1000x1000x10.journal data/1000x10000x10.journal data/10000x1000x10.journal data/10000x10000x10.journal data/100000x1000x10.journal \
 | samplejournals: data/sample.journal data/100x100x10.journal data/1000x1000x10.journal data/1000x10000x10.journal data/10000x1000x10.journal data/10000x10000x10.journal data/100000x1000x10.journal \ | ||||||
| # 	$(call def-help,samplejournals,\
 | 	$(call def-help,samplejournals, regenerate standard sample journals in data/ ) | ||||||
| # 	generate standard sample journals in data/\
 |  | ||||||
| # 	)
 |  | ||||||
| 
 | 
 | ||||||
| # data/sample.journal:
 | data/sample.journal: | ||||||
| # 	true # XXX should probably regenerate this
 | 	true # XXX should probably regenerate this | ||||||
| 
 | 
 | ||||||
| # data/100x100x10.journal: tools/generatejournal
 | data/100x100x10.journal: tools/generatejournal | ||||||
| # 	tools/generatejournal 100 100 10 >$@
 | 	tools/generatejournal 100 100 10 >$@ | ||||||
| 
 | 
 | ||||||
| # data/1000x1000x10.journal: tools/generatejournal
 | data/1000x1000x10.journal: tools/generatejournal | ||||||
| # 	tools/generatejournal 1000 1000 10 >$@
 | 	tools/generatejournal 1000 1000 10 >$@ | ||||||
| 
 | 
 | ||||||
| # data/1000x10000x10.journal: tools/generatejournal
 | data/1000x10000x10.journal: tools/generatejournal | ||||||
| # 	tools/generatejournal 1000 10000 10 >$@
 | 	tools/generatejournal 1000 10000 10 >$@ | ||||||
| 
 | 
 | ||||||
| # data/10000x1000x10.journal: tools/generatejournal
 | data/10000x1000x10.journal: tools/generatejournal | ||||||
| # 	tools/generatejournal 10000 1000 10 >$@
 | 	tools/generatejournal 10000 1000 10 >$@ | ||||||
| 
 | 
 | ||||||
| # data/10000x10000x10.journal: tools/generatejournal
 | data/10000x10000x10.journal: tools/generatejournal | ||||||
| # 	tools/generatejournal 10000 10000 10 >$@
 | 	tools/generatejournal 10000 10000 10 >$@ | ||||||
| 
 | 
 | ||||||
| # data/100000x1000x10.journal: tools/generatejournal
 | data/100000x1000x10.journal: tools/generatejournal | ||||||
| # 	tools/generatejournal 100000 1000 10 >$@
 | 	tools/generatejournal 100000 1000 10 >$@ | ||||||
| 
 | 
 | ||||||
| ###############################################################################
 | ###############################################################################
 | ||||||
| $(call def-help-subsection,DOCUMENTATION:) | $(call def-help-subsection,DOCUMENTATION:) | ||||||
|  | |||||||
							
								
								
									
										31
									
								
								tools/runhledgercov
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										31
									
								
								tools/runhledgercov
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,31 @@ | |||||||
|  | #!/usr/bin/env python | ||||||
|  | # runhledgercov "HPCCOMMAND [HPCARGS]" [HLEDGERARGS] | ||||||
|  | # | ||||||
|  | # A front-end that resets the tix count, runs hledgercov (the HPC-enabled build) | ||||||
|  | # with the specified hledger args, and runs hpc with the specified hpc args. | ||||||
|  | # Should be run from hledger's top source directory. | ||||||
|  | # | ||||||
|  | # Eg: | ||||||
|  | # hledger$ tools/runhledgercov report test | ||||||
|  | # hledger$ tools/runhledgercov "markup --destdir=coverage" test 'some unit test' | ||||||
|  | 
 | ||||||
|  | hledgercov="hledgercov" | ||||||
|  | verbosity = 0  # 0=no output, 1=stderr only, 2=stdout+stderr | ||||||
|  | 
 | ||||||
|  | import sys, os | ||||||
|  | 
 | ||||||
|  | hpcargs, hledgerargs = sys.argv[1], ' '.join(sys.argv[2:]) | ||||||
|  | 
 | ||||||
|  | # remove old tix files | ||||||
|  | os.system("rm -f %s.tix" % hledgercov) | ||||||
|  | 
 | ||||||
|  | # run the hpc-enabled binary with the specified hledger arguments to generate tix files | ||||||
|  | if verbosity<1: | ||||||
|  |     os.system("bin/%s %s >/dev/null 2>&1" % (hledgercov,hledgerargs)) | ||||||
|  | elif verbosity==1: | ||||||
|  |     os.system("bin/%s %s >/dev/null" % (hledgercov,hledgerargs)) | ||||||
|  | else: | ||||||
|  |     os.system("bin/%s %s" % (hledgercov,hledgerargs)) | ||||||
|  | 
 | ||||||
|  | # run the specified hpc command on the tix files | ||||||
|  | os.system("hpc %s %s" % (hpcargs,hledgercov)) | ||||||
| @ -1,31 +0,0 @@ | |||||||
| #!/usr/bin/env python |  | ||||||
| # runhledgerhpc "HPCCOMMAND [HPCARGS]" [HLEDGERARGS] |  | ||||||
| # |  | ||||||
| # A front-end that resets the tix count, runs hledgerhpc with the |  | ||||||
| # specified hledger args, and runs hpc with the specified hpc args. |  | ||||||
| # Should be run from hledger's top source directory. |  | ||||||
| # |  | ||||||
| # Eg: |  | ||||||
| # hledger$ tools/runhledgerhpc report test |  | ||||||
| # hledger$ tools/runhledgerhpc "markup --destdir=coverage" test 'some unit test' |  | ||||||
| 
 |  | ||||||
| hledgerhpc="hledgerhpc" |  | ||||||
| verbosity = 0  # 0=no output, 1=stderr only, 2=stdout+stderr |  | ||||||
| 
 |  | ||||||
| import sys, os |  | ||||||
| 
 |  | ||||||
| hpcargs, hledgerargs = sys.argv[1], ' '.join(sys.argv[2:]) |  | ||||||
| 
 |  | ||||||
| # remove old tix files |  | ||||||
| os.system("rm -f %s.tix" % hledgerhpc) |  | ||||||
| 
 |  | ||||||
| # run the hpc-enabled binary with the specified hledger arguments to generate tix files |  | ||||||
| if verbosity<1: |  | ||||||
|     os.system("bin/%s %s >/dev/null 2>&1" % (hledgerhpc,hledgerargs)) |  | ||||||
| elif verbosity==1: |  | ||||||
|     os.system("bin/%s %s >/dev/null" % (hledgerhpc,hledgerargs)) |  | ||||||
| else: |  | ||||||
|     os.system("bin/%s %s" % (hledgerhpc,hledgerargs)) |  | ||||||
| 
 |  | ||||||
| # run the specified hpc command on the tix files |  | ||||||
| os.system("hpc %s %s" % (hpcargs,hledgerhpc)) |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user