yaml_bench Scanner benchmark, and files are not realoaded from HDD by default.
This commit is contained in:
parent
6aa50b8898
commit
0d89c2beb1
|
@ -1,4 +1,5 @@
|
|||
|
||||
module dyaml.yaml_bench;
|
||||
//Benchmark that loads, and optionally extracts data from and/or emits a YAML file.
|
||||
|
||||
import std.conv;
|
||||
|
@ -21,7 +22,12 @@ void help()
|
|||
" -h --help Show this help information.\n"
|
||||
" -g --get Extract data from the file (using Node.as()).\n"
|
||||
" -d --dump Dump the loaded data (to YAML_FILE.dump).\n"
|
||||
" -r --runs=NUM Repeat the benchmark NUM times.\n";
|
||||
" -r --runs=NUM Repeat parsing the file NUM times.\n"
|
||||
" --reload Reload the file from the diskl on every repeat\n"
|
||||
" By default, the file is loaded to memory once\n"
|
||||
" and repeatedly parsed from memory.\n"
|
||||
" -s --scan-onlly Do not execute the entire parsing process, only\n"
|
||||
" scanning. Overrides '--dump'.\n";
|
||||
writeln(help);
|
||||
}
|
||||
|
||||
|
@ -59,6 +65,8 @@ void main(string[] args)
|
|||
{
|
||||
bool get = false;
|
||||
bool dump = false;
|
||||
bool reload = false;
|
||||
bool scanOnly = false;
|
||||
uint runs = 1;
|
||||
string file = null;
|
||||
|
||||
|
@ -71,7 +79,9 @@ void main(string[] args)
|
|||
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;
|
||||
case "--reload": reload = true; break;
|
||||
case "--scan-only", "-s": scanOnly = true; break;
|
||||
case "--runs", "-r": runs = parts[1].to!uint; break;
|
||||
default: writeln("\nUnknown argument: ", arg, "\n\n"); help(); return;
|
||||
}
|
||||
else
|
||||
|
@ -95,9 +105,18 @@ void main(string[] args)
|
|||
|
||||
try
|
||||
{
|
||||
import std.file;
|
||||
void[] fileInMemory;
|
||||
if(!reload) { fileInMemory = std.file.read(file); }
|
||||
while(runs--)
|
||||
{
|
||||
auto nodes = Loader(file).loadAll();
|
||||
if(reload) { fileInMemory = std.file.read(file); }
|
||||
if(scanOnly)
|
||||
{
|
||||
Loader(fileInMemory).scanBench();
|
||||
continue;
|
||||
}
|
||||
auto nodes = Loader(fileInMemory).loadAll();
|
||||
if(dump)
|
||||
{
|
||||
Dumper(file ~ ".dump").dump(nodes);
|
||||
|
|
Loading…
Reference in a new issue