This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests for profile and trace output
- Loading branch information
1 parent
7c05b9f
commit 5160b33
Showing
9 changed files
with
123 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# set from top makefile | ||
OS:= | ||
MODEL:= | ||
DMD:= | ||
DRUNTIME:= | ||
DRUNTIMESO:= | ||
QUIET:= | ||
LINKDL:= | ||
|
||
SRC:=src | ||
ROOT:=./obj/$(OS)/$(MODEL) | ||
TESTS:=$(addprefix $(ROOT)/,$(addsuffix .done,profile profilegc both)) | ||
|
||
DIFF:=diff | ||
GREP:=grep | ||
|
||
ifneq (default,$(MODEL)) | ||
MODEL_FLAG:=-m$(MODEL) | ||
endif | ||
CFLAGS:=$(MODEL_FLAG) -Wall | ||
DFLAGS:=$(MODEL_FLAG) -w -I../../src -I../../import -I$(SRC) -L$(DRUNTIME) -defaultlib= -debuglib= | ||
|
||
.PHONY: all clean | ||
all: $(TESTS) | ||
|
||
$(ROOT)/profile.done: DFLAGS+=-profile | ||
$(ROOT)/profile.done: $(ROOT)/%.done: $(ROOT)/% | ||
@echo Testing $* | ||
@rm -f $(ROOT)/mytrace.log $(ROOT)/mytrace.def | ||
$(QUIET)$(ROOT)/$* $(ROOT)/mytrace.log $(ROOT)/mytrace.def | ||
$(QUIET)$(GREP) -q '1 .*_Dmain' $(ROOT)/mytrace.log | ||
$(QUIET)$(GREP) -q '1000 .*uint profile.foo(uint)' $(ROOT)/mytrace.log | ||
$(QUIET)$(DIFF) mytrace.def.exp $(ROOT)/mytrace.def | ||
@touch $@ | ||
|
||
$(ROOT)/profilegc.done: DFLAGS+=-profile=gc | ||
$(ROOT)/profilegc.done: $(ROOT)/%.done: $(ROOT)/% | ||
@echo Testing $* | ||
@rm -f $(ROOT)/myprofilegc.log | ||
$(QUIET)$(ROOT)/$* $(ROOT)/myprofilegc.log | ||
$(QUIET)$(DIFF) myprofilegc.log.exp $(ROOT)/myprofilegc.log | ||
@touch $@ | ||
|
||
$(ROOT)/both.done: DFLAGS+=-profile -profile=gc | ||
$(ROOT)/both.done: $(ROOT)/%.done: $(ROOT)/% | ||
@echo Testing $* | ||
@rm -f $(ROOT)/both.log $(ROOT)/both.def $(ROOT)/bothgc.log | ||
$(QUIET)$(ROOT)/$* $(ROOT)/both.log $(ROOT)/both.def $(ROOT)/bothgc.log | ||
$(QUIET)$(GREP) -q '1 .*_Dmain' $(ROOT)/mytrace.log | ||
$(QUIET)$(GREP) -q '1000 .*both.Num\* both.foo(uint)' $(ROOT)/both.log | ||
$(QUIET)$(DIFF) both.def.exp $(ROOT)/both.def | ||
$(QUIET)$(DIFF) bothgc.log.exp $(ROOT)/bothgc.log | ||
@touch $@ | ||
|
||
$(ROOT)/%: $(SRC)/%.d | ||
$(QUIET)$(DMD) $(DFLAGS) -of$(ROOT)/$* $< | ||
|
||
clean: | ||
rm -rf obj *.log *.def |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
FUNCTIONS | ||
_Dmain | ||
_D4both3fooFkZPS4both3Num | ||
_D4both3Num6__ctorMFNckZS4both3Num |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bytes allocated, type, function, file:line | ||
4000 both.Num both.foo src/both.d:15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bytes allocated, type, function, file:line | ||
4 uint D main src/profilegc.d:6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
FUNCTIONS | ||
_Dmain | ||
_D7profile3fooFkZk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import core.runtime; | ||
|
||
struct Num | ||
{ | ||
pragma(inline, false) this(uint val) | ||
{ | ||
this.val = val; | ||
} | ||
|
||
uint val; | ||
} | ||
|
||
pragma(inline, false) Num* foo(uint val) | ||
{ | ||
return new Num(val); | ||
} | ||
|
||
__gshared uint sum; | ||
|
||
void main(string[] args) | ||
{ | ||
trace_setlogfilename(args[1]); | ||
trace_setdeffilename(args[2]); | ||
profilegc_setlogfilename(args[3]); | ||
foreach (uint i; 0 .. 1_000) | ||
sum += foo(i).val; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import core.runtime; | ||
|
||
pragma(inline, false) uint foo(uint val) | ||
{ | ||
return val * 2; | ||
} | ||
|
||
__gshared uint sum; | ||
|
||
void main(string[] args) | ||
{ | ||
trace_setlogfilename(args[1]); | ||
trace_setdeffilename(args[2]); | ||
foreach (uint i; 0 .. 1_000) | ||
sum += foo(i); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import core.runtime; | ||
|
||
void main(string[] args) | ||
{ | ||
profilegc_setlogfilename(args[1]); | ||
auto p = new uint; | ||
} |