public SqlPopulator(SqlStorageContext context, IMetricRecorder recorder)
 {
     _context = context;
     _recorder = recorder;
 }
        public void Measure(CancellationToken cancel)
        {
            var batchKey = Guid.NewGuid();
            var rnd = new Random();
            var tasks = Enumerable
                .Range(0, 100)
                .Select((i) => Task<TimeSpan>.Factory.StartNew(() =>
                    {
                        var context =
                            new SqlStorageContext(CloudConfigurationManager.GetSetting("SqlStore.ConnectionString"));
                        var id = rnd.Next(0, 10000000 - 1);
                        var stopWatch = Stopwatch.StartNew();
                        var result = context.LoremIpsum.Find(id);
                        return stopWatch.Elapsed;
                    },
                                                               cancel))
                ;
            Task.WaitAll(tasks.ToArray(), cancel);

            _recorder.Report(
                "MeasureSql",
                batchKey.ToString(),
                tasks.Aggregate(
                    TimeSpan.Zero,
                    (elapsed, task) => elapsed.Add(task.Result)
                    ));
        }