diff --git a/examples/yaml_bench/yaml_bench.d b/examples/yaml_bench/yaml_bench.d index bb8446e2..6bf6b1d6 100644 --- a/examples/yaml_bench/yaml_bench.d +++ b/examples/yaml_bench/yaml_bench.d @@ -12,6 +12,8 @@ import std.range; import std.stdio; import std.string; import dyaml; +import dyaml.reader; +import dyaml.scanner; ///Get data out of every node. void extract(ref Node document) @safe @@ -115,15 +117,21 @@ void main(string[] args) //@safe else { fileWorkingCopy[] = fileInMemory[]; } void[] fileToLoad = reload ? fileInMemory : fileWorkingCopy; - auto loader = Loader.fromBuffer(fileToLoad); if(scanOnly) { - loader.scanBench(); - return; + auto reader = new Reader(cast(ubyte[])fileToLoad, "benchmark"); + auto scanner = Scanner(reader); + while(!scanner.empty) + { + scanner.popFront(); + } + } + else + { + auto loader = Loader.fromBuffer(fileToLoad); + loader.resolver = resolver; + nodes = loader.array; } - - loader.resolver = resolver; - nodes = loader.array; } void runDumpBenchmark() @safe { diff --git a/source/dyaml/loader.d b/source/dyaml/loader.d index 0569863e..c238134d 100644 --- a/source/dyaml/loader.d +++ b/source/dyaml/loader.d @@ -248,23 +248,6 @@ struct Loader } return currentNode; } - - // Scan all tokens, throwing them away. Used for benchmarking. - void scanBench() @safe - { - try - { - while(!scanner_.empty) - { - scanner_.popFront(); - } - } - catch(YAMLException e) - { - throw new YAMLException("Unable to scan YAML from stream " ~ - name_ ~ " : " ~ e.msg, e.file, e.line); - } - } } /// Load single YAML document from a file: @safe unittest