Skip to content

Commit

Permalink
Added make *-diff rules, quick commands to compare sizes
Browse files Browse the repository at this point in the history
This required a patch to the --diff flag for the scripts to ignore
a missing file. This enables the useful one liner for making comparisons
with potentially missing previous versions:

    ./scripts/code.py lfs.o -d lfs.o.code.csv -o lfs.o.code.csv

    function (0 added, 0 removed)            old     new    diff
    TOTAL                                  25476   25476      +0

One downside, these previous files are easy to delete as a part of make
clean, which limits their usefulness for comparing configuration
changes...
  • Loading branch information
geky committed Mar 11, 2022
1 parent 0a2ff3b commit 50ad2ad
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 55 deletions.
52 changes: 34 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ endif
ifneq ($(OBJDUMP),objdump)
override STRUCTSFLAGS += --objdump-tool="$(OBJDUMP)"
endif
override CODEFLAGS += -S
override DATAFLAGS += -S
override STACKFLAGS += -S
override STRUCTSFLAGS += -S
override COVERAGEFLAGS += -s


# commands
Expand All @@ -94,35 +89,55 @@ size: $(OBJ)
tags:
$(CTAGS) --totals --c-types=+p $(shell find -H -name '*.h') $(SRC)

.PHONY: calls
calls: $(CGI)
./scripts/calls.py $^ $(CALLSFLAGS)

.PHONY: test
test:
./scripts/test.py $(TESTFLAGS)
.SECONDEXPANSION:
test%: tests/test$$(firstword $$(subst \#, ,%)).toml
./scripts/test.py $@ $(TESTFLAGS)

.PHONY: code
code: $(OBJ)
./scripts/code.py $^ $(CODEFLAGS)
./scripts/code.py $^ -S $(CODEFLAGS)

.PHONY: code-diff
code-diff: $(OBJ)
./scripts/code.py $^ -d $(TARGET).code.csv -o $(TARGET).code.csv $(CODEFLAGS)

.PHONY: data
data: $(OBJ)
./scripts/data.py $^ $(DATAFLAGS)
./scripts/data.py $^ -S $(DATAFLAGS)

.PHONY: calls
calls: $(CGI)
./scripts/calls.py $^ $(CALLSFLAGS)
.PHONY: data-diff
data-diff: $(OBJ)
./scripts/data.py $^ -d $(TARGET).data.csv -o $(TARGET).data.csv $(DATAFLAGS)

.PHONY: stack
stack: $(CGI)
./scripts/stack.py $^ $(STACKFLAGS)
./scripts/stack.py $^ -S $(STACKFLAGS)

.PHONY: stack-diff
stack-diff: $(CGI)
./scripts/stack.py $^ -d $(TARGET).stack.csv -o $(TARGET).stack.csv $(STACKFLAGS)

.PHONY: structs
structs: $(OBJ)
./scripts/structs.py $^ $(STRUCTSFLAGS)
./scripts/structs.py $^ -S $(STRUCTSFLAGS)

.PHONY: test
test:
./scripts/test.py $(TESTFLAGS)
.SECONDEXPANSION:
test%: tests/test$$(firstword $$(subst \#, ,%)).toml
./scripts/test.py $@ $(TESTFLAGS)
.PHONY: structs-diff
structs-diff: $(OBJ)
./scripts/structs.py $^ -d $(TARGET).structs.csv -o $(TARGET).structs.csv $(STRUCTSFLAGS)

.PHONY: coverage
coverage:
./scripts/coverage.py $(BUILDDIR)tests/*.toml.info -s $(COVERAGEFLAGS)

.PHONY: coverage-diff
coverage-diff:
./scripts/coverage.py $(BUILDDIR)tests/*.toml.info $(COVERAGEFLAGS)

# rules
Expand All @@ -148,6 +163,7 @@ $(BUILDDIR)%.ci: %.c
.PHONY: clean
clean:
rm -f $(TARGET)
rm -f $(TARGET).*.csv
rm -f $(OBJ)
rm -f $(CGI)
rm -f $(DEP)
Expand Down
17 changes: 10 additions & 7 deletions scripts/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,16 @@ def main(**args):

# find previous results?
if args.get('diff'):
with open(args['diff']) as f:
r = csv.DictReader(f)
prev_results = [
( result['file'],
result['function'],
int(result['code_size']))
for result in r]
try:
with open(args['diff']) as f:
r = csv.DictReader(f)
prev_results = [
( result['file'],
result['function'],
int(result['code_size']))
for result in r]
except FileNotFoundError:
prev_results = []

prev_total = 0
for _, _, size in prev_results:
Expand Down
19 changes: 11 additions & 8 deletions scripts/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,17 @@ def main(**args):

# find previous results?
if args.get('diff'):
with open(args['diff']) as f:
r = csv.DictReader(f)
prev_results = [
( result['file'],
result['function'],
int(result['coverage_hits']),
int(result['coverage_count']))
for result in r]
try:
with open(args['diff']) as f:
r = csv.DictReader(f)
prev_results = [
( result['file'],
result['function'],
int(result['coverage_hits']),
int(result['coverage_count']))
for result in r]
except FileNotFoundError:
prev_results = []

prev_total_hits, prev_total_count = 0, 0
for _, _, hits, count in prev_results:
Expand Down
17 changes: 10 additions & 7 deletions scripts/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,16 @@ def main(**args):

# find previous results?
if args.get('diff'):
with open(args['diff']) as f:
r = csv.DictReader(f)
prev_results = [
( result['file'],
result['function'],
int(result['data_size']))
for result in r]
try:
with open(args['diff']) as f:
r = csv.DictReader(f)
prev_results = [
( result['file'],
result['function'],
int(result['data_size']))
for result in r]
except FileNotFoundError:
prev_results = []

prev_total = 0
for _, _, size in prev_results:
Expand Down
19 changes: 11 additions & 8 deletions scripts/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,17 @@ def main(**args):

# find previous results?
if args.get('diff'):
with open(args['diff']) as f:
r = csv.DictReader(f)
prev_results = [
( result['file'],
result['function'],
int(result['stack_frame']),
float(result['stack_limit']))
for result in r]
try:
with open(args['diff']) as f:
r = csv.DictReader(f)
prev_results = [
( result['file'],
result['function'],
int(result['stack_frame']),
float(result['stack_limit']))
for result in r]
except FileNotFoundError:
prev_results = []

prev_total_frame = 0
prev_total_limit = 0
Expand Down
17 changes: 10 additions & 7 deletions scripts/structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,16 @@ def main(**args):

# find previous results?
if args.get('diff'):
with open(args['diff']) as f:
r = csv.DictReader(f)
prev_results = [
( result['file'],
result['struct'],
int(result['struct_size']))
for result in r]
try:
with open(args['diff']) as f:
r = csv.DictReader(f)
prev_results = [
( result['file'],
result['struct'],
int(result['struct_size']))
for result in r]
except FileNotFoundError:
prev_results = []

prev_total = 0
for _, _, size in prev_results:
Expand Down

0 comments on commit 50ad2ad

Please sign in to comment.