Exemplo n.º 1
0
        /// <summary>
        /// Write metrics to filepath
        /// </summary>
        /// <param name="filePath">Filepath to write metrics to</param>
        public void ExportMetrics(string filepath)
        {
            using var writer = File.CreateText(filepath);

            writer.WriteLine(GpuMetricSample.GetHeader());

            foreach (var sample in _MetricsSamples)
            {
                WriteSample(writer, sample);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Write metrics for single model to standard output
        /// </summary>
        public void ExportMetrics()
        {
            using var writer = new StreamWriter(Console.OpenStandardOutput())
                  {
                      AutoFlush = true
                  };

            writer.WriteLine(GpuMetricSample.GetHeaderFormatted());

            foreach (var sample in _MetricsSamples)
            {
                Console.WriteLine(sample.ToStringFormatted());
            }
        }
Exemplo n.º 3
0
        public void GenerateMetrics()
        {
            if (_LatestSample == null)
            {
                _LatestSample = new GpuMetricSample();
            }

            if (_UpdateFrequency.TotalSeconds <= 0)
            {
                Console.WriteLine("Ignoring GenerateMetrics: Update frequency must be greater than zero.");
                return;
            }

            var numUpdates = (int)(_RunLength.TotalSeconds / _UpdateFrequency.TotalSeconds);

            ClearCachedMetrics();

            for (var i = 0; i < numUpdates; i++)
            {
                Thread.Sleep(_UpdateFrequency);
                UpdateLatestMetrics();
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Prints the metrics in a sample
 /// </summary>
 /// <param name="writer">Writer to write values to.</param>
 /// <param name="sample">Sample to write.</param>
 private void WriteSample(StreamWriter writer, GpuMetricSample sample)
 {
     writer.WriteLine(sample.ToString());
 }
Exemplo n.º 5
0
 /// <summary>
 /// Adds a new sample to Metrics Collector
 /// </summary>
 /// <param name="modelName">Name of model associated with sample.</param>
 /// <param name="batchSize">Number of models sent per batch to server.</param>
 /// <param name="concurrencyValue">Number of concurrent threads used by server.</param>
 /// <returns>Returns new sample.</returns>
 public GpuMetricSample AddNewSample(string modelName, int batchSize, int concurrencyValue)
 {
     _LatestSample = new GpuMetricSample(modelName, batchSize, concurrencyValue);
     _MetricsSamples.Add(_LatestSample);
     return(_LatestSample);
 }