Ejemplo n.º 1
0
        public void Generate(
            string path,
            long size,
            int bufferSize,
            int percentOfAppearance
            )
        {
            Analyze(path, size);

            _bytesWritten = 0;

            if (bufferSize > size)
            {
                bufferSize = (int)size;
            }

            var workers = (int)(size / bufferSize);

            if (workers > 10)
            {
                workers = 10;
            }

            try
            {
                _fileAdapter.Delete(path);
                _fileWriter.BeginWrite(path, bufferSize);

                Parallel.For(0, workers, w => GenerateLines(w, bufferSize, size, percentOfAppearance));

                _fileWriter.SetLength(size);
            }
            finally
            {
                _fileWriter.EndWrite();
            }
        }