Ejemplo n.º 1
0
        public void Dispose()
        {
            _watch.Stop();

            long physicalMemoryUsageInMB = System.Diagnostics.Process.GetCurrentProcess().PeakWorkingSet64 / 1024 / 1024;

            _ch.Info("Physical memory usage(MB): {0}", physicalMemoryUsageInMB);

            long virtualMemoryUsageInMB = System.Diagnostics.Process.GetCurrentProcess().PeakVirtualMemorySize64 / 1024 / 1024;

            _ch.Info("Virtual memory usage(MB): {0}", virtualMemoryUsageInMB);

            // Print the fractions of seconds if elapsed time is small enough that fractions matter
            Double elapsedSeconds = (Double)_watch.ElapsedMilliseconds / 1000;

            if (elapsedSeconds > 99)
            {
                elapsedSeconds = Math.Round(elapsedSeconds);
            }

            // REVIEW: This is \n\n is to prevent changes across bunch of baseline files.
            // Ideally we should change our comparison method to ignore empty lines.
            _ch.Info("{0}\t Time elapsed(s): {1}\n\n", DateTime.UtcNow, elapsedSeconds);

            using (var pipe = _host.StartPipe <TelemetryMessage>("TelemetryPipe"))
            {
                _ch.AssertValue(pipe);

                pipe.Send(TelemetryMessage.CreateMetric("TLC_RunTime", elapsedSeconds));
                pipe.Send(TelemetryMessage.CreateMetric("TLC_PhysicalMemoryUsageInMB", physicalMemoryUsageInMB));
                pipe.Send(TelemetryMessage.CreateMetric("TLC_VirtualMemoryUsageInMB", virtualMemoryUsageInMB));
            }
        }
            protected void SendTelemetryMetricCore(IChannelProvider prov, Dictionary <string, double> averageMetric)
            {
                using (var pipe = prov.StartPipe <TelemetryMessage>("TelemetryPipe"))
                {
                    Contracts.AssertValue(pipe);

                    if (averageMetric != null)
                    {
                        foreach (var pair in averageMetric)
                        {
                            pipe.Send(TelemetryMessage.CreateMetric(pair.Key, pair.Value, null));
                        }
                    }
                }
            }