diff --git a/cdc.d b/cdc.d index 5a26ca5..b535531 100755 --- a/cdc.d +++ b/cdc.d @@ -138,7 +138,7 @@ void main(string[] args) scope(failure){help(); core.stdc.stdlib.exit(-1);} - string[] extra_args = ["-w", "-wi"]; + string[] extra_args = ["-gc", "-w", "-wi"]; args = args[1 .. $]; foreach(arg; args) @@ -154,7 +154,7 @@ void main(string[] args) } if(args.length > 0 && args[$ - 1][0] != '-'){target = args[$ - 1];} - string[] dbg = ["-gc", "-debug"]; + string[] dbg = ["-debug"]; string[] optimize = ["-O", "-inline", "-release"]; string[] lib_src = ["dyaml/", "yaml.d"]; diff --git a/examples/yaml_bench/Makefile b/examples/yaml_bench/Makefile index 6fc6a4b..3aacd69 100644 --- a/examples/yaml_bench/Makefile +++ b/examples/yaml_bench/Makefile @@ -1,5 +1,5 @@ main: - dmd -w -I../../ -L-L../../ -L-ldyaml yaml_bench.d + dmd -w -gc -I../../ -L-L../../ -L-ldyaml yaml_bench.d clean: rm yaml_bench yaml_bench.o diff --git a/examples/yaml_bench/yaml_bench.d b/examples/yaml_bench/yaml_bench.d index 6d05072..6689ea6 100644 --- a/examples/yaml_bench/yaml_bench.d +++ b/examples/yaml_bench/yaml_bench.d @@ -1,8 +1,10 @@ //Benchmark that loads, and optionally extracts data from and/or emits a YAML file. +import std.conv; import std.datetime; import std.stdio; +import std.string; import yaml; ///Print help information. @@ -18,7 +20,8 @@ void help() "Available options:\n" " -h --help Show this help information.\n" " -g --get Extract data from the file (using Node.get()).\n" - " -d --dump Dump the loaded data (to YAML_FILE.dump).\n"; + " -d --dump Dump the loaded data (to YAML_FILE.dump).\n" + " -r --runs=NUM Repeat the benchmark NUM times.\n"; writeln(help); } @@ -56,16 +59,19 @@ void main(string[] args) { bool get = false; bool dump = false; + uint runs = 1; string file = null; //Parse command line args foreach(arg; args[1 .. $]) { - if(arg[0] == '-') switch(arg) + auto parts = arg.split("="); + if(arg[0] == '-') switch(parts[0]) { case "--help", "-h": help(); return; case "--get", "-g": get = true; break; case "--dump", "-d": dump = true; break; + case "--runs", "-r": runs = to!uint(parts[1]); break; default: writeln("\nUnknown argument: ", arg, "\n\n"); help(); return; } else @@ -89,14 +95,17 @@ void main(string[] args) try { - auto nodes = Loader(file).loadAll(); - if(dump) + while(runs--) { - Dumper(file ~ ".dump").dump(nodes); - } - if(get) foreach(ref node; nodes) - { - extract(node); + auto nodes = Loader(file).loadAll(); + if(dump) + { + Dumper(file ~ ".dump").dump(nodes); + } + if(get) foreach(ref node; nodes) + { + extract(node); + } } } catch(YAMLException e) diff --git a/examples/yaml_gen/config.yaml b/examples/yaml_gen/config.yaml index 5c54e1b..910b637 100644 --- a/examples/yaml_gen/config.yaml +++ b/examples/yaml_gen/config.yaml @@ -1,8 +1,9 @@ root-type: seq documents: 2 complex-keys: false -min-nodes-per-document: 512 -encoding: utf-32 +collection-keys: false +min-nodes-per-document: 65536 +encoding: utf-8 indent: 4 text-width: 40 diff --git a/examples/yaml_gen/yaml_gen.d b/examples/yaml_gen/yaml_gen.d index 9bc5630..0bb082c 100644 --- a/examples/yaml_gen/yaml_gen.d +++ b/examples/yaml_gen/yaml_gen.d @@ -155,7 +155,8 @@ Node genBinary(bool root = false) Node nodes(in bool root, Node range, in string tag, in bool set = false) { - auto types = typesCollection ~ (set ? typesScalarKey : typesScalar); + auto types = config["collection-keys"].as!bool ? typesCollection : []; + types ~= (set ? typesScalarKey : typesScalar); Node[] nodes; if(root)