Beispiel #1
0
        private static InstanceCountEntity[] GetData()
        {
            var rows = new InstanceCountEntity[] {
                new InstanceCountEntity(t1, "c1")
                {
                    DurationMilliseconds = durationMs, CurrentActive = 6, MachineSize = 20
                },
                new InstanceCountEntity(t2, "c1")
                {
                    DurationMilliseconds = durationMs, CurrentActive = 6, MachineSize = 20
                },
            };

            return(rows);
        }
Beispiel #2
0
        public async Task <FunctionVolumeTimelineEntry[]> GetVolumeAsync(DateTime startTime, DateTime endTime, int numberBuckets)
        {
            var query = InstanceCountEntity.GetQuery(startTime, endTime);

            var iter = await EpochTableIterator.NewAsync(_tableLookup);

            var results = await iter.SafeExecuteQuerySegmentedAsync <InstanceCountEntity>(query, startTime, endTime);

            InstanceCountEntity[] rows = results.Results;

            var startTicks = startTime.Ticks;
            var endTicks   = endTime.Ticks;
            var data       = ProjectionHelper.Work(rows, startTicks, endTicks, numberBuckets);

            int[]  totalCounts      = new int[numberBuckets];
            double bucketWidthTicks = ((double)(endTicks - startTicks)) / numberBuckets;

            foreach (var row in rows)
            {
                int idx = (int)((row.GetTicks() - startTicks) / bucketWidthTicks);
                if (idx >= 0 && idx < numberBuckets)
                {
                    totalCounts[idx] += row.TotalThisPeriod;
                }
            }

            // coerce data
            var chart = new FunctionVolumeTimelineEntry[numberBuckets];

            for (int i = 0; i < numberBuckets; i++)
            {
                var    ticks = data[i].Item1;
                var    time  = new DateTime(ticks);
                double value = data[i].Item2;
                chart[i] = new FunctionVolumeTimelineEntry
                {
                    Time           = time,
                    Volume         = value,
                    InstanceCounts = totalCounts[i]
                };
            }

            return(chart);
        }
Beispiel #3
0
        public Task <FunctionVolumeTimelineEntry[]> GetVolumeAsync(DateTime startTime, DateTime endTime, int numberBuckets)
        {
            var query = InstanceCountEntity.GetQuery(startTime, endTime);

            IEnumerable <InstanceCountEntity> results = _instanceTable.ExecuteQuery(query);
            var rows = results.ToArray();

            var startTicks = startTime.Ticks;
            var endTicks   = endTime.Ticks;
            var data       = ProjectionHelper.Work(rows, startTicks, endTicks, numberBuckets);

            int[]  totalCounts      = new int[numberBuckets];
            double bucketWidthTicks = ((double)(endTicks - startTicks)) / numberBuckets;

            foreach (var row in rows)
            {
                int idx = (int)((row.GetTicks() - startTicks) / bucketWidthTicks);
                if (idx >= 0 && idx < numberBuckets)
                {
                    totalCounts[idx] += row.TotalThisPeriod;
                }
            }

            // coerce data
            var chart = new FunctionVolumeTimelineEntry[numberBuckets];

            for (int i = 0; i < numberBuckets; i++)
            {
                var    ticks = data[i].Item1;
                var    time  = new DateTime(ticks);
                double value = data[i].Item2;
                chart[i] = new FunctionVolumeTimelineEntry
                {
                    Time           = time,
                    Volume         = value,
                    InstanceCounts = totalCounts[i]
                };
            }

            return(Task.FromResult(chart));
        }
 private static Tuple<long, double>[] Work(InstanceCountEntity[] rows, long startTicks, long endTicks, int numberBuckets)
 {
     return ProjectionHelper.Work(rows, startTicks, endTicks, numberBuckets);
 }
 private static InstanceCountEntity[] GetData()
 {
     var rows = new InstanceCountEntity[] {
         new InstanceCountEntity(t1, "c1") { DurationMilliseconds = durationMs, CurrentActive = 6, MachineSize = 20 },
         new InstanceCountEntity(t2, "c1") { DurationMilliseconds = durationMs, CurrentActive = 6, MachineSize = 20 },
     };
     return rows;
 }