示例#1
0
        static void Main(string[] args)
        {
            /*---------------     FS -------------*/
            var filePath = @"f:\temp\Amadori";
            var ff = new FileSystemFactory(new FileSystemShardingStrategy[] { new FileSystemPerYearShardingStrategy(), new FileSystemPerMonthShardingStrategy() }, new InputValueBuilder());
            Account account = new FileSystemAccount(filePath, ff, new FileSystemPerYearShardingStrategy());

            /*---------------  AZURE  -------------*/
            //var azureAccount = new CloudStorageAccount(new StorageCredentials("onenergy", "SOKk3P1fokgf9RoxrL/SJ5SIapsMdx6X1vTj7KyB7iMvCp0fcW7qLb53+KjHTDecycf257c2tpCuK5O5OtqQkA=="), true);
            //var tableClient = azureAccount.CreateCloudTableClient();
            //var blobClient = azureAccount.CreateCloudBlobClient();
            //var container = blobClient.GetContainerReference("values-onimenergy");
            //container.CreateIfNotExists();
            //var bf = new AzureBlobFactory(new AzureBlobShardingStrategy[] { new AzureBlobPerYearShardingStrategy(), new AzureBlobPerMonthShardingStrategy() }, new InputValueBuilder());
            //Account account = new AzureBlobAccount(container, bf);

            //RunImport(account);
            account.Read_Streams();
        }
示例#2
0
        static void Main(string[] args)
        {
            Stopwatch watch = null;

            //watch = Stopwatch.StartNew();
            //int count = 0;
            //for (int i = 0; i < int.MaxValue; i++)
            //    count++;
            //watch.Stop();
            //Console.WriteLine("cpu speed : " + watch.Elapsed);

            /*---------------     FS -------------*/
            var filePath = @"e:\temp\Amadori";
            var ff = new FileSystemFactory(new FileSystemShardingStrategy[] { new FileSystemPerYearShardingStrategy(), new FileSystemPerMonthShardingStrategy() }, new EventBuilder());
            Account account = new FileSystemAccount(filePath, ff, new FileSystemPerYearShardingStrategy());

            /*---------------  AZURE  -------------*/
            //var azureAccount = new CloudStorageAccount(new StorageCredentials("valeriob", "2SzgTAaG11U0M1gQ19SNus/vv1f0efwYOwZHL1w9YhTKEYsU1ul+s/ke92DOE1wIeCKYz5CuaowtDceUvZW2Rw=="), true);
            //var tableClient = azureAccount.CreateCloudTableClient();
            //var blobClient = azureAccount.CreateCloudBlobClient();
            //var container = blobClient.GetContainerReference("onenergy-amadori");
            //container.CreateIfNotExists();
            //var bf = new AzureBlobFactory(new AzureBlobShardingStrategy[] { new AzureBlobPerYearShardingStrategy(), new AzureBlobPerMonthShardingStrategy() });
            //Account account = new AzureBlobAccount(container, bf);

            //var indexTable = tableClient.GetTableReference("index");
            //var operation = TableOperation.InsertOrReplace(null);
            //indexTable.Execute(operation);

            //while (true)
            //{
            //    watch = Stopwatch.StartNew();
            //    using (var buffer = new MemoryStream())
            //    {
            //        var blob = blobClient.GetBlobReferenceFromServer(new Uri("http://valeriob.blob.core.windows.net/onenergy-amadori/11a6f393-c4b9-42ba-8a18-bccd2adcbbee/2008"));
            //        blob.DownloadToStream(buffer);
            //    }
            //    watch.Stop();
            //    Console.WriteLine(watch.Elapsed);
            //}
            //Console.ReadLine();
            //return;

            //watch = Stopwatch.StartNew();
            //account.Reset();
            //account.Write_Streams(2000, 5, OgniMinuto);
            //watch.Stop();
            //Console.WriteLine(watch.Elapsed);

            watch = Stopwatch.StartNew();
            account.Read_Streams();
            watch.Stop();
            Console.WriteLine(watch.Elapsed);

            Console.WriteLine("hit enter to loop reading");
            Console.ReadLine();

            var streams = account.GetStreams().ToArray();
            var random = new Random();
            var id = random.Next(streams.Length);
            var stream = streams[id];
            var rep = account.BuildRepository(stream);
            while (true)
            {

                watch = Stopwatch.StartNew();
                var count = rep.GetRawValues(new DateTime(2012, 1, 1)).Count();
                watch.Stop();

                Console.WriteLine("Raw : " + watch.Elapsed);

                //watch = Stopwatch.StartNew();
                //rep.Get_Values(new DateTime(2012, 1, 1)).ToList();
                //watch.Stop();

                //Console.WriteLine("'Deserialized' : " + watch.Elapsed);
            }

            Console.ReadLine();
        }