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

TokenizeStream() public method

Parse all tokens from the specified Stream, put them into the input List.
public TokenizeStream ( Stream s, List tokens ) : bool
s Stream
tokens List The List to put tokens in.
return bool
        public bool TokenizeStream(Stream s, List<Token> tokens)
        {
            textReader = new StreamReader(s);
            return (Tokenize(tokens));
        }

Usage Example

Example #1
0
        /// <summary>
        /// Use the supplied tokenizer to tokenize the specified stream
        /// and time it.
        /// </summary>
        /// <param name="tokenizer"></param>
        /// <param name="stream"></param>
        /// <returns>Total milliseconds per parse.</returns>
        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);
        }