-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
65 lines (56 loc) · 2.36 KB
/
Program.cs
File metadata and controls
65 lines (56 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
namespace Microsoft.WindowsAzure.Storage.Blob
{
using System;
using System.IO;
using System.Net;
using System.Threading;
using System.Diagnostics;
using System.IO.Compression;
using System.Security.Cryptography;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using Microsoft.WindowsAzure.Storage.RetryPolicies;
using System.Threading.Tasks;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Program
{
public static CloudBlob GetBlob()
{
string connectionString = "DefaultEndpointsProtocol=http;AccountName=[accountname];AccountKey=[accountkey]";
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer blobContainer = blobClient.GetContainerReference("rffyg");
return (CloudBlob)blobContainer.GetBlobReference("00814");
}
static void Main(string[] args)
{
CloudBlob blob = GetBlob();
Stopwatch time = Stopwatch.StartNew();
DoUploadDownloadFileTask(blob, Int32.Parse(args[0]) /*parallel IO count*/, Convert.ToInt64(args[1])*1024*1024 /* range size per IO */).Wait();
time.Stop();
Console.WriteLine("Parallel I/O Count {0}.", args[0]);
Console.WriteLine("Download size per range {0} in MB.", args[1]);
Console.WriteLine("Download has been completed in {0} seconds.", time.Elapsed.TotalSeconds.ToString());
Console.ReadLine();
}
private static async Task DoUploadDownloadFileTask(CloudBlob blob, int parallelCount, long chunkSize)
{
string outputFileName = Path.GetTempFileName();
try
{
long? offset = null;
long? length = null;
CloudBlob source = (CloudBlob)blob;
ParallelDownloadSettings parallelDownloadSettings = new ParallelDownloadSettings(source, outputFileName, FileMode.Create, offset, length, parallelCount, chunkSize);
ParallelDownload parallelDownload = ParallelDownload.Start(parallelDownloadSettings);
await parallelDownload.Task;
}
finally
{
//File.Delete(outputFileName);
}
}
}
}