コード例 #1
0
        public void JobComplete(IImageJobInstrumentation job)
        {
            IncrementCounter("image_jobs");

            var timestamp = Stopwatch.GetTimestamp();
            var s_w       = job.SourceWidth.GetValueOrDefault(0);
            var s_h       = job.SourceHeight.GetValueOrDefault(0);
            var f_w       = job.FinalWidth.GetValueOrDefault(0);
            var f_h       = job.FinalHeight.GetValueOrDefault(0);


            if (job.SourceWidth.HasValue && job.SourceHeight.HasValue)
            {
                var prefix = "source_multiple_";
                if (s_w % 4 == 0 && s_h % 4 == 0)
                {
                    counters.Increment(prefix + "4x4");
                }

                if (s_w % 8 == 0 && s_h % 8 == 0)
                {
                    counters.Increment(prefix + "8x8");
                }

                if (s_w % 8 == 0)
                {
                    counters.Increment(prefix + "8x");
                }

                if (s_h % 8 == 0)
                {
                    counters.Increment(prefix + "x8");
                }

                if (s_w % 16 == 0 && s_h % 16 == 0)
                {
                    counters.Increment(prefix + "16x16");
                }
            }



            //(builder.SettingsModifier as PipelineConfig).GetImageBuilder

            var readPixels  = job.SourceWidth.GetValueOrDefault(0) * job.SourceHeight.GetValueOrDefault(0);
            var wrotePixels = job.FinalWidth.GetValueOrDefault(0) * job.FinalHeight.GetValueOrDefault(0);

            if (readPixels > 0)
            {
                sourceMegapixels.Report(readPixels);

                sourceWidths.Report(s_w);
                sourceHeights.Report(s_h);

                sourceAspectRatios.Report(s_w * 100 / s_h);
            }

            if (wrotePixels > 0)
            {
                outputMegapixels.Report(wrotePixels);


                outputWidths.Report(f_w);
                outputHeights.Report(f_h);
                outputAspectRatios.Report(f_w * 100 / f_h);
            }

            if (readPixels > 0 && wrotePixels > 0)
            {
                scalingRatios.Report(s_w * 100 / f_w);
                scalingRatios.Report(s_h * 100 / f_h);
            }

            jobs.Record(timestamp, 1);
            decodedPixels.Record(timestamp, readPixels);
            encodedPixels.Record(timestamp, wrotePixels);


            job_times.Report(job.TotalTicks);
            decode_times.Report(job.DecodeTicks);
            encode_times.Report(job.EncodeTicks);
            job_other_time.Report(job.TotalTicks - job.DecodeTicks - job.EncodeTicks);

            if (job.SourceFileExtension != null)
            {
                var ext = job.SourceFileExtension.ToLowerInvariant().TrimStart('.');
                counters.Increment("source_file_ext_" + ext);
            }

            PostJobQuery(job.FinalCommandKeys);

            NoticeDomains(job.ImageDomain, job.PageDomain);
        }
コード例 #2
0
        public IInfoAccumulator GetReportPairs()
        {
            var q        = new QueryAccumulator().Object;
            var timeThis = Stopwatch.StartNew();

            // Increment when we break the schema (or, as in v4, reduce the frequency)
            q.Add("reporting_version", 100);

            Process.Value.Add(q);
            Hardware.Value.Add(q);
            if (_lastInfoProviders != null)
            {
                foreach (var provider in _lastInfoProviders)
                {
                    provider?.Add(q);
                }
            }
            //Add counters
            foreach (var pair in counters.GetCounts())
            {
                q.Add(pair.Key, pair.Value.ToString());
            }

            //Add rates
            foreach (var rate in rates)
            {
                q.Add(rate.Key + "_total", rate.Value.RecordedTotal);
                foreach (var pair in rate.Value.GetStats())
                {
                    var basekey = rate.Key + "_per_" + pair.Interval.Unit;
                    q.Add(basekey + "_max", pair.Max);
                }
            }

            //Add percentiles
            foreach (var d in percentiles)
            {
                var values = d.Value.GetPercentiles(Percentiles.Select(p => p / 100.0f));
                q.Add(values.Zip(Percentiles,
                                 (result, percent) =>
                                 new KeyValuePair <string, string>(
                                     d.Key + "_" + percent.ToString() + "th", result.ToString())));
            }


            q.Add("image_domains",
                  string.Join(",", GetPopularUniqueValues("image_domains", 8)));
            q.Add("page_domains",
                  string.Join(",", GetPopularUniqueValues("page_domains", 8)));

            var originalKeys = GetPopularUniqueValues("original_query_keys", 40).ToArray();

            q.Add("query_keys",
                  string.Join(",", originalKeys));
            q.Add("extra_job_query_keys",
                  string.Join(",", GetPopularUniqueValues("job_query_keys", 40).Except(originalKeys).Take(2)));

            timeThis.Stop();
            collect_info_times.Report(timeThis.ElapsedTicks);
            return(q);
        }
コード例 #3
0
ファイル: GlobalPerf.cs プロジェクト: timgaunt/resizer
        internal void JobComplete(ImageBuilder builder, ImageJob job)
        {
            var timestamp = Stopwatch.GetTimestamp();
            var s_w       = job.SourceWidth.GetValueOrDefault(0);
            var s_h       = job.SourceHeight.GetValueOrDefault(0);
            var f_w       = job.FinalWidth.GetValueOrDefault(0);
            var f_h       = job.FinalHeight.GetValueOrDefault(0);


            if (job.SourceWidth.HasValue && job.SourceHeight.HasValue)
            {
                var prefix = "source_multiple_";
                if (s_w % 4 == 0 && s_h % 4 == 0)
                {
                    counters.Increment(prefix + "4x4");
                }
                if (s_w % 8 == 0 && s_h % 8 == 0)
                {
                    counters.Increment(prefix + "8x8");
                }
                if (s_w % 8 == 0)
                {
                    counters.Increment(prefix + "8x");
                }
                if (s_h % 8 == 0)
                {
                    counters.Increment(prefix + "x8");
                }
                if (s_w % 16 == 0 && s_h % 16 == 0)
                {
                    counters.Increment(prefix + "16x16");
                }
            }



            //(builder.SettingsModifier as PipelineConfig).GetImageBuilder

            var readPixels  = job.SourceWidth.GetValueOrDefault(0) * job.SourceHeight.GetValueOrDefault(0);
            var wrotePixels = job.FinalWidth.GetValueOrDefault(0) * job.FinalHeight.GetValueOrDefault(0);

            if (readPixels > 0)
            {
                sourceMegapixels.Report(readPixels);

                sourceWidths.Report(s_w);
                sourceHeights.Report(s_h);

                sourceAspectRatios.Report(s_w * 100 / s_h);
            }
            if (wrotePixels > 0)
            {
                outputMegapixels.Report(wrotePixels);


                outputWidths.Report(f_w);
                outputHeights.Report(f_h);
                outputAspectRatios.Report(f_w * 100 / f_h);
            }
            if (readPixels > 0 && wrotePixels > 0)
            {
                scalingRatios.Report(s_w * 100 / f_w);
                scalingRatios.Report(s_h * 100 / f_h);
            }

            jobs.Record(timestamp, 1);
            decodedPixels.Record(timestamp, readPixels);
            encodedPixels.Record(timestamp, wrotePixels);


            job_times.Report(job.TotalTicks);
            decode_times.Report(job.DecodeTicks);
            encode_times.Report(job.EncodeTicks);
            job_other_time.Report(job.TotalTicks - job.DecodeTicks - job.EncodeTicks);

            if (job.SourcePathData != null)
            {
                var ext = PathUtils.GetExtension(job.SourcePathData).ToLowerInvariant().TrimStart('.');
                counters.Increment("source_file_ext_" + ext);
            }

            var plugins = builder.EncoderProvider as PluginConfig;

            if (plugins != null)
            {
                Plugins.Value.Notify(plugins);
            }

            PostJobQuery(job.Instructions);

            if (System.Web.HttpContext.Current?.Request != null)
            {
                NoticeDomains(System.Web.HttpContext.Current.Request);
            }
            if (httpModules == null)
            {
                httpModules = System.Web.HttpContext.Current?.ApplicationInstance?.Modules;
            }
        }