Пример #1
0
        public void DownloadSmallerFileWriteToStream()
        {
            //8 threads
            //MaxChunkSize = 1048576
            //FileSize = 5242880

            var             uri    = new Uri(Constants.FIVE_MEG_FILE);
            var             path   = SafePath("sites_vcf.gz");
            Action <string> logger = (message) => { };
            var             timer  = new Stopwatch();

            timer.Start();
            using (var fs = new FileStream(path, FileMode.OpenOrCreate))
            {
                ILargeFileDownloadParameters parameters = new LargeFileDownloadWithStreamParameters(uri, fs, 1048576,
                                                                                                    maxThreads: 8);
                Task task = parameters.DownloadAsync(logger: logger);
                task.Wait(TimeSpan.FromMinutes(1));
                timer.Stop();
                Debug.WriteLine("Took {0} threads {1} ms", 8, timer.ElapsedMilliseconds);

                //try to open the file
                ValidateGZip(path, parameters.FileSize, Constants.FIVE_MEG_CHECKSUM);
            }
        }
Пример #2
0
        public void DownloadSmallFilesWithNonOptimizedStream(int threadCount)
        {
            var             uri    = new Uri(Constants.TWENTY_MEG_FILE);
            var             path   = DownloadTests.SafePath("sites_vcf.gz");
            Action <string> logger = (message) => { };
            var             timer  = new Stopwatch();

            timer.Start();
            var manager = new BufferManager(new[] { new BufferQueueSetting(SimpleHttpGetByRangeClient.BUFFER_SIZE, (uint)threadCount), new BufferQueueSetting(LargeFileDownloadParameters.DEFAULT_MAX_CHUNK_SIZE) });

            LargeFileDownloadParameters.EnsureCleanFile(path, true);
            using (var stream = new FileStream(path, FileMode.OpenOrCreate))
            {
                ILargeFileDownloadParameters parameters = new LargeFileDownloadWithStreamParameters(uri, stream,
                                                                                                    Constants.TWENTY_MEG_FILE_LENGTH,
                                                                                                    maxThreads:
                                                                                                    threadCount);
                Task task = parameters.DownloadAsync(logger: logger, bufferManager: manager);
                task.Wait(TimeSpan.FromMinutes(5));
                timer.Stop();

                Debug.WriteLine("Took {0} threads {1} ms", threadCount, timer.ElapsedMilliseconds);
                //try to open the file
                DownloadTests.ValidateGZip(path, parameters.FileSize, Constants.TWENTY_CHECKSUM);
            }
        }
        public void DownloadSmallFilesWithNonOptimizedStream(int threadCount)
        {
            var uri = new Uri(Constants.TWENTY_MEG_FILE);
            var path = DownloadTests.SafePath("sites_vcf.gz");
            Action<string> logger = (message) => { };
            var timer = new Stopwatch();
            timer.Start();
            var manager = new BufferManager(new[] { new BufferQueueSetting(SimpleHttpGetByRangeClient.BUFFER_SIZE, (uint)threadCount), new BufferQueueSetting(LargeFileDownloadParameters.DEFAULT_MAX_CHUNK_SIZE) });
            LargeFileDownloadParameters.EnsureCleanFile(path, true);
            using (var stream = new FileStream(path, FileMode.OpenOrCreate))
            {
                ILargeFileDownloadParameters parameters = new LargeFileDownloadWithStreamParameters(uri, stream,
                                                                                                    Constants.TWENTY_MEG_FILE_LENGTH,
                                                                                                    maxThreads:
                                                                                                        threadCount);
                Task task = parameters.DownloadAsync(logger: logger, bufferManager: manager);
                task.Wait(TimeSpan.FromMinutes(5));
                timer.Stop();

                Debug.WriteLine("Took {0} threads {1} ms", threadCount, timer.ElapsedMilliseconds);
                //try to open the file
                DownloadTests.ValidateGZip(path, parameters.FileSize, Constants.TWENTY_CHECKSUM);
            }
        }
Пример #4
0
        public void DownloadSmallerFileWriteToStream()
        {
            //8 threads
            //MaxChunkSize = 1048576
            //FileSize = 5242880

            var uri = new Uri(Constants.FIVE_MEG_FILE);
            var path = SafePath("sites_vcf.gz");
            Action<string> logger = (message) => { };
            var timer = new Stopwatch();
            timer.Start();
            using (var fs = new FileStream(path, FileMode.OpenOrCreate))
            {
                ILargeFileDownloadParameters parameters = new LargeFileDownloadWithStreamParameters(uri,fs , 1048576,
                                                                                                    maxThreads: 8);
                Task task = parameters.DownloadAsync(logger: logger);
                task.Wait(TimeSpan.FromMinutes(1));
                timer.Stop();
                Debug.WriteLine("Took {0} threads {1} ms", 8, timer.ElapsedMilliseconds);

            //try to open the file
            ValidateGZip(path, parameters.FileSize, Constants.FIVE_MEG_CHECKSUM);
                 }
        }