예제 #1
0
        public void Can_count_lines_ranged()
        {
            var expected = 10000L;

            using (var fixture = new FlatFileFixture((int)expected, Encoding.UTF8))
            {
                var sw    = Stopwatch.StartNew();
                var lines = LineReader.CountLines(fixture.FileStream, Encoding.UTF8);
                Assert.Equal(expected, lines);
                Trace.WriteLine($"{lines} lines took {sw.Elapsed} to read.");
            }
        }
예제 #2
0
        public void Can_count_lines_ranged()
        {
            const long expected = 10000L;

            using var fixture = new FlatFileFixture((int)expected, Encoding.UTF8);

            var range = new RangeStream(fixture.FileStream, 0, 5000);
            var sw    = Stopwatch.StartNew();
            var lines = LineReader.CountLines(range, Encoding.UTF8);

            Assert.True(lines < 150);
            _console.WriteLine($"{lines} lines took {sw.Elapsed} to read.");
        }
예제 #3
0
        private void CheckRowCount(Stream stream)
        {
            var linesInFile = LineReader.CountLines(stream, Encoding);

            if (linesInFile < RowCount)
            {
                throw new ArgumentException($"file does not have at least {RowCount} rows");
            }

            if (stream.CanSeek)
            {
                stream.Position = 0L;
            }
        }
예제 #4
0
 public long LineReader_CountLines()
 {
     return(LineReader.CountLines(File.OpenRead(_files[rowCount]), Encoding.UTF8, null, CancellationToken.None));
 }