Exemplo n.º 1
0
        public Snapshot Insert(DroneSnapshotDto snapshot)
        {
            Snapshot entity = mapper.Map <DroneSnapshotDto, Snapshot>(snapshot);

            snapshotRepository.Insert(entity);

            SnapshotModel model = mapper.Map <DroneSnapshotDto, SnapshotModel>(snapshot);

            reportService.Update(model);

            return(entity);
        }
Exemplo n.º 2
0
        private void EmitReport(IReportContext context)
        {
            log.Debug(Debugging.Report_Emitting.FormatWith(context.RequestFactory.Id));

            IList <ProfileItem> results  = context.Snapshot();
            IList <RequestItem> pending  = context.Pending();
            TimeSpan            duration = context.Duration;

            int successful = results.Count(r => r.Response.StatusCode == HttpStatusCode.OK);
            int timedOut   = results.Count(r => r.Response.ResponseStatus == ResponseStatus.TimedOut);

            double responseTime = 0;

            if (results.Any() || pending.Any())
            {
                responseTime = (pending.Sum(item => item.Elapsed.TotalSeconds) + results.Sum(item => item.Elapsed.TotalSeconds))
                               / (results.Count() + pending.Count());
            }
            var dto = new DroneSnapshotDto
            {
                Name            = Info.Report_Name.FormatWith(context.RequestFactory.Id, context.InternalId),
                ExecutionId     = context.RequestFactory.ExecutionId,
                DroneId         = context.DroneId,
                Started         = context.Started,
                Duration        = duration,
                CurrentWorkload = new DroneWorkloadDto
                {
                    Average             = results.Count / duration.TotalSeconds,
                    AverageResponseTime = responseTime,
                    Completed           = results.Count,
                    Successful          = successful,
                    Failed   = results.Count - successful,
                    TimedOut = timedOut
                },
                VirtualUsers = context.Users()
            };

            Task.Factory.StartNew(() => report(dto));             // report async.
        }
Exemplo n.º 3
0
 private int GetCountByStatus(DroneSnapshotDto dto, VirtualUserStatus status)
 {
     return(dto.VirtualUsers.Where(vu => vu.Status == status).Sum(vu => vu.Count));
 }
Exemplo n.º 4
0
 public EmptyResult Snapshot(DroneSnapshotDto dto)
 {
     snapshotService.Insert(dto);
     return(new EmptyResult());
 }