Beispiel #1
0
        // GET api/samples
        public HttpResponseMessage Get()
        {
            try
            {
                var users      = _usersRepository.GetUsers();
                var statuses   = _statusesRepository.GetStatuses();
                var sampleDtos = from s in _samplesRepository.GetSamples()
                                 join u in users on s.CreatedBy equals u.UserId
                                 join st in statuses on s.StatusId equals st.StatusId
                                 select new SampleDto
                {
                    SampleId           = s.SampleId,
                    Barcode            = s.Barcode,
                    CreatedAt          = s.CreatedAt,
                    CreatedById        = s.CreatedBy,
                    CreatedByFirstName = u.FirstName,
                    CreatedByLastName  = u.LastName,
                    StatusId           = s.StatusId,
                    Status             = st.Status1
                };

                var pairs = Request.GetQueryNameValuePairs();
                if (pairs.Any())
                {
                    sampleDtos = filterSampleDtos(sampleDtos, pairs);
                }

                return(Request.CreateResponse(HttpStatusCode.OK, sampleDtos.ToList()));
            }
            catch (Exception e)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError,
                                              "There was a problem getting you that data."));
            }
        }
        public override IStatModel FromSamples(ISamplesRepository samplesRepository)
        {
            var performanceSamples = samplesRepository.GetSamples() as PerformanceSample[] ?? samplesRepository.GetSamples().ToArray();

            var mle = performanceSamples.Length / performanceSamples.Sum(t => t.Duration.TotalMilliseconds); // TODO: Check

            return(new ExponentialStatModel(mle));
        }
Beispiel #3
0
        public override IStatModel FromSamples(ISamplesRepository samplesRepository)
        {
            var performanceSamples = samplesRepository.GetSamples() as PerformanceSample[] ?? samplesRepository.GetSamples().ToArray();

            var min = performanceSamples.Min(t => t.Duration.TotalMilliseconds);
            var max = performanceSamples.Max(t => t.Duration.TotalMilliseconds);

            return(new UniformStatModel(min, max));
        }
        public override IStatModel FromSamples(ISamplesRepository samplesRepository)
        {
            var performanceSamples = samplesRepository.GetSamples() as PerformanceSample[] ?? samplesRepository.GetSamples().ToArray();

            var estMean = performanceSamples.Sum(t => t.Duration.TotalMilliseconds);

            estMean = estMean / performanceSamples.Length;

            var estVariance = performanceSamples.Sum(t => Math.Pow((t.Duration.TotalMilliseconds - estMean), 2));

            estVariance = estVariance / performanceSamples.Length;

            return(new NormalStatModel(estMean, Math.Sqrt(estVariance)));
        }
Beispiel #5
0
        public override IStatModel FromSamples(ISamplesRepository samplesRepository)
        {
            var performanceSamples = samplesRepository.GetSamples() as PerformanceSample[] ?? samplesRepository.GetSamples().ToArray();
            var logSamples         =
                (from ps in performanceSamples
                 select Math.Log(ps.Duration.TotalMilliseconds)).ToArray();

            var estLogScale = logSamples.Sum(t => t);

            estLogScale = estLogScale / logSamples.Length;

            var estShape = logSamples.Sum(t => Math.Pow(t - estLogScale, 2));

            estShape = estShape / logSamples.Length;

            return(new LogNormalStatModel(estLogScale, Math.Sqrt(estShape)));
        }
Beispiel #6
0
 public override IStatModel FromSamples(ISamplesRepository samplesRepository)
 {
     return(new CustomStatModel(samplesRepository.GetSamples()));
 }