RTools.Util.StreamTokenizer.SpeedTestParse C# (CSharp) Method

SpeedTestParse() protected static method

Use the supplied tokenizer to tokenize the specified stream and time it.
protected static SpeedTestParse ( StreamTokenizer tokenizer, Stream stream ) : double
tokenizer StreamTokenizer
stream Stream
return double
        protected static double SpeedTestParse(StreamTokenizer tokenizer,
            Stream stream)
        {
            GC.Collect();
            List<Token> tokens = new List<Token>();
            DateTime start = System.DateTime.UtcNow;
            int cycles = 100;
            for (int i = 0; i < cycles; i++)
            {
                tokenizer.TokenizeStream(stream, tokens);
                stream.Position = 0;
            }
            TimeSpan duration = System.DateTime.UtcNow - start;

            return (duration.TotalMilliseconds / cycles);
        }