add basic profiling support

This commit is contained in:
Lance Vick 2023-10-09 14:55:37 -07:00
parent 832b9640c5
commit f0d39c33bc
Signed by: lrvick
GPG Key ID: 8E47A1EC35A1551D
1 changed files with 25 additions and 0 deletions

View File

@ -52,6 +52,31 @@ PATH_PREFIX := /home/build/.local/bin:/home/build/$(CACHE_DIR)/bin:/home/build/$
PREFIX := $(HOME)/.local PREFIX := $(HOME)/.local
XDG_CONFIG_HOME := $(HOME)/.config XDG_CONFIG_HOME := $(HOME)/.config
ifneq ($(TOOLCHAIN_PROFILE),false)
mkc := $(shell mkdir -p $(CACHE_DIR_ROOT))
ifndef TOOLCHAIN_PROFILE_RUNNING
rmp := $(shell rm -f $(CACHE_DIR_ROOT)/toolchain-profile.csv)
TOOLCHAIN_PROFILE_START := 0
TOOLCHAIN_PROFILE_RUNNING := true
export TOOLCHAIN_PROFILE_RUNNING TOOLCHAIN_PROFILE_START
endif
.PHONY: toolchain-profile
toolchain-profile:
@echo Target build times:
@column -s, -t < $(CACHE_DIR_ROOT)/toolchain-profile.csv
endif
define toolchain_profile_start
$(eval TOOLCHAIN_PROFILE_START=$(shell date +%s))
echo START=$(TOOLCHAIN_PROFILE_START)
@printf "%s," "$@" >> $(CACHE_DIR_ROOT)/toolchain-profile.csv
endef
define toolchain_profile_end
printf "%s\n" "$$(date -d@$$(($$(date +%s)-$(TOOLCHAIN_PROFILE_START))) -u +%H:%M:%S)" >> $(CACHE_DIR_ROOT)/toolchain-profile.csv
endef
export export
include $(CONFIG_DIR)/make.env include $(CONFIG_DIR)/make.env