CDC and yaml_bench makefile now always compile with debug

symbols. yaml_bench can now repeat the benchmark many times in a
single run. yaml_gen can now disable collection keys in mappings.
This commit is contained in:
Ferdinand Majerech 2011-10-23 16:10:27 +02:00
parent 13ea5f0c24
commit 915428c8ed
5 changed files with 26 additions and 15 deletions

View file

@ -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

View file

@ -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)