From 6aa50b889804542cc2a9051eeb17fecc0f8664cb Mon Sep 17 00:00:00 2001 From: Ferdinand Majerech Date: Sat, 2 Aug 2014 23:26:46 +0200 Subject: [PATCH] A benchmark Loader method that scans a file but throws away the tokens. --- source/dyaml/loader.d | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/source/dyaml/loader.d b/source/dyaml/loader.d index 7383ef7..b1f6c18 100644 --- a/source/dyaml/loader.d +++ b/source/dyaml/loader.d @@ -360,6 +360,21 @@ struct Loader } } + // Scan all tokens, throwing them away. Used for benchmarking. + void scanBench() @safe + { + try while(scanner_.checkToken()) + { + scanner_.getToken(); + } + catch(YAMLException e) + { + throw new YAMLException("Unable to scan YAML from stream " ~ + name_ ~ " : " ~ e.msg); + } + } + + // Parse and return all events. Used for debugging. immutable(Event)[] parse() @safe {