From: Leandro Lucarella Date: Sun, 23 Aug 2009 20:01:23 +0000 (-0300) Subject: micro/split.d: Take the file to split from the command line X-Git-Url: https://git.llucax.com/software/dgc/dgcbench.git/commitdiff_plain/688f2efa838b0dbc5b9dd592a9cea0ba2058e9f5?ds=sidebyside;hp=5b0d31198806563101200a3b5d435b1ddd6c2dbd micro/split.d: Take the file to split from the command line The Makefile is adapted to make possible to pass arguments to an arbitrary benchmark program. --- diff --git a/micro/Makefile b/micro/Makefile index ce310b0..e48a2e2 100644 --- a/micro/Makefile +++ b/micro/Makefile @@ -29,7 +29,7 @@ P_DC = @echo ' DC $@'; P_LD = @echo ' LD $@'; P_PLOT = @echo ' PLOT $@'; P_MAKE = @echo ' MAKE $@'; -P_RUN = @echo ' RUN $<'; +P_RUN = @echo ' RUN $< $(arg1) $(arg2) $(arg3)'; P_AWK = @echo ' AWK $@'; endif @@ -64,10 +64,12 @@ stat: $(stat) .PRECIOUS: $(STAT_DIR)/%.c.csv $(STAT_DIR)/%.a.csv $(STAT_DIR)/%.c.csv $(STAT_DIR)/%.a.csv: $(BIN_DIR)/% - $(P_RUN) ./$< + $(P_RUN) ./$< $(args) $P mv gc-collections.csv $(STAT_DIR)/$*.c.csv $P mv gc-mallocs.csv $(STAT_DIR)/$*.a.csv +# special command line arguments for benchmarks +$(STAT_DIR)/split.c.csv $(STAT_DIR)/split.a.csv: override args := bible.txt .PRECIOUS: $(STAT_DIR)/%.h.csv $(STAT_DIR)/%.h.csv: $(STAT_DIR)/%.a.csv diff --git a/micro/split.d b/micro/split.d index b042323..319082b 100644 --- a/micro/split.d +++ b/micro/split.d @@ -8,9 +8,12 @@ import tango.text.Util: delimit; import tango.util.Convert: to; int main(char[][] args) { - auto txt = cast(byte[]) File.get("bible.txt"); - auto n = (args.length > 1) ? to!(uint)(args[1]) : 1; - if (n < 1) n = 1; + if (args.length < 2) + return 1; + auto txt = cast(byte[]) File.get(args[1]); + auto n = (args.length > 2) ? to!(uint)(args[2]) : 1; + if (n < 1) + n = 1; while (--n) txt ~= txt; auto words = delimit!(byte)(txt, cast(byte[]) " \t\n\r");