public UnitRecord(string unit, double conversion, MetricType type, bool defaultPrint) { this.Unit = unit; this.Conversion = conversion; this.Type = type; this.DefaultPrint = defaultPrint; }
/// <summary> /// /// </summary> /// <param name="appExe">Full path to test executable</param> /// <param name="metricType">Type of interval measurement</param> /// <param name="scenarioName">Scenario name for reporting</param> /// <param name="processWillExit">true: process exits on its own. False: process does not exit, send close.</param> /// <param name="timeout">Max wait for process to exit</param> /// <param name="measurementDelay">Allowed time for startup window</param> /// <param name="iterations">Number of measured iterations</param> /// <param name="appArgs">optional arguments to test executable</param> /// <param name="logFileName">optional log file. Default is appExe.startup.log</param> /// <param name="workingDir">optional working directory</param> /// <param name="warmup">enables/disables warmup iteration</param> /// <param name="traceName">trace name</param> /// <param name="guiApp">true: app under test is a GUI app, false: console</param> /// <param name="skipProfileIteration">true: skip full results iteration</param> /// <param name="reportJsonPath">path to save report json</param> /// <param name="iterationSetup">command to set up before each iteration</param> /// <param name="setupArgs">arguments of iterationSetup</param> /// <param name="iterationCleanup">command to clean up after each iteration</param> /// <param name="cleanupArgs">arguments of iterationCleanup</param> /// <param name="traceDirectory">Directory to put files in (defaults to current directory)</param> /// <param name="environmentVariables">Environment variables set for test processes (example: var1=value1;var2=value2)</param> /// <param name="innerLoopCommand">Environment variables set for test processes (example: var1=value1;var2=value2)</param> /// <param name="innerLoopCommandArgs">Environment variables set for test processes (example: var1=value1;var2=value2)</param> /// <param name="runWithoutExit">Run the main test process without handling shutdown</param> /// <returns></returns> static int Main(string appExe, MetricType metricType, string scenarioName, string traceName, bool processWillExit = false, int iterations = 5, string iterationSetup = "", string setupArgs = "", string iterationCleanup = "", string cleanupArgs = "", int timeout = 60, int measurementDelay = 15, string appArgs = "", string logFileName = "", string workingDir = "", bool warmup = true, bool guiApp = true, bool skipProfileIteration = false, string reportJsonPath = "", string traceDirectory = null, string environmentVariables = null, string innerLoopCommand = "", string innerLoopCommandArgs = "", bool runWithoutExit = false ) { Logger logger = new Logger(String.IsNullOrEmpty(logFileName) ? $"{appExe}.startup.log" : logFileName);
public IImmutableDictionary <MetricName, IMetric> GetSample(MetricType excludeTypes = MetricType.None) { if (excludeTypes.HasFlagFast(MetricType.All)) { return(NoSample); } var filtered = new Dictionary <MetricName, IMetric>(); foreach (var entry in _cache.Get <List <MetricName> >(Common.Constants.Categories.Metrics)) { switch (entry.Class.Name) { case nameof(GaugeMetric) when excludeTypes.HasFlagFast(MetricType.Gauge): case nameof(CounterMetric) when excludeTypes.HasFlagFast(MetricType.Counter): case nameof(MeterMetric) when excludeTypes.HasFlagFast(MetricType.Meter): case nameof(HistogramMetric) when excludeTypes.HasFlagFast(MetricType.Histogram): case nameof(TimerMetric) when excludeTypes.HasFlagFast(MetricType.Timer): continue; default: filtered.Add(entry, _cache.Get <IMetric>(entry.CacheKey)); break; } } return(filtered.ToImmutableDictionary()); }
/// <summary> /// Initializes a new instance of the <see cref="Metric"/> class. /// </summary> /// <param name="name">The name.</param> /// <param name="explanationUrl">The explanation url.</param> /// <param name="metricType">The type of the metric.</param> /// <param name="value">The value.</param> public Metric(string name, Uri explanationUrl, MetricType metricType, decimal?value) { this.Name = name ?? throw new ArgumentNullException(nameof(name)); this.ExplanationUrl = explanationUrl; this.MetricType = metricType; this.Value = value; }
public void FindClientActionToInvoke_Should_return_Correct_Client_Method(MetricType metricType) { var metric = new Metric() { Name = "default_aspx", Value = 12334234, Time = DateTime.Now, Type = metricType }; _clientFactory.Expect(x => x.FindClient<IMetricClient>()).Return(_metricClient); var method = _service.FindClientActionToInvoke<IMetricClient>(metric); method.Invoke(metric.Name, metric.Value, metric.Time); switch (metricType) { case MetricType.Count: _metricClient.AssertWasCalled(x => x.LogCount(metric.Name, metric.Value, metric.Time)); break; case MetricType.Timing: _metricClient.AssertWasCalled(x => x.LogTiming(metric.Name, metric.Value, metric.Time)); break; case MetricType.Gauge: _metricClient.AssertWasCalled(x => x.LogGauge(metric.Name, metric.Value, metric.Time)); break; case MetricType.Set: _metricClient.AssertWasCalled(x => x.LogSet(metric.Name, metric.Value, metric.Time)); break; } }
public void CreateOrUpdateMetric(Guid releaseWindowId, MetricType metricType, DateTime? executedOn = null, Guid? externalId = null) { DataMetric existingMetric = null; var release = ReleaseWindowRepository.GetSatisfiedBy(x => x.ExternalId == releaseWindowId); if (release == null) throw new EntityNotFoundException(typeof(ReleaseWindow), releaseWindowId); if (externalId != null && !Guid.Empty.Equals(externalId)) { existingMetric = MetricsRepository.GetSatisfiedBy(o => o.ExternalId == externalId); } if (existingMetric == null) { existingMetric = MetricsRepository.GetSatisfiedBy(x => x.ReleaseWindow.ExternalId == releaseWindowId && x.MetricType == metricType); } if (existingMetric != null) { existingMetric.ExecutedOn = executedOn.HasValue ? executedOn.Value.ToUniversalTime() : (DateTime?)null; MetricsRepository.Update(existingMetric); return; } CreateMetric(release.ReleaseWindowId, metricType, executedOn, externalId); }
public void ValidateOneDimension(MetricType metricType) { var metrics = new List <Metric>(); using var meter = new Meter(nameof(ValidateOneDimension)); using var provider = Sdk.CreateMeterProviderBuilder() .AddMeter(meter.Name) .AddInMemoryExporter(metrics) .Build(); var dataPointType = DataPointType.Aggregation; string name = null; if (metricType == MetricType.DoubleSum) { name = "TestDoubleCounter"; var doubleCounter = meter.CreateCounter <double>(name); doubleCounter.Add(123.45, new KeyValuePair <string, object>("tag", "value")); } else if (metricType == MetricType.DoubleGauge) { name = "TestGauge"; meter.CreateObservableGauge( name, () => new List <Measurement <double> >() { new(123.45, new KeyValuePair <string, object>("tag", "value")), });
public IMetricsWriter WriteType(MetricType metricType) { ValidateState(nameof(WriteType), WriterState.MetricStarted | WriterState.HelpWritten); if (_hasData) { Write(_newLine); } _hasData = true; Write(_typePrefix); if (_currentMetricEncoded == default) { _currentMetricEncoded = Write(_currentMetricName); } else { Write(_currentMetricEncoded.AsSpan()); } Write(_tokenSeparator); Write(_metricTypesMap[metricType]); _state = WriterState.TypeWritten; return(this); }
private static double ProjectMetric(SourceVideoMetric metricRow, MetricType metricName) { switch (metricName) { case MetricType.Views: return((double)((metricRow?.ViewCount) ?? 0)); case MetricType.Likes: return((double)((metricRow?.LikeCount) ?? 0)); case MetricType.Reactions: return((double)((metricRow?.ReactionCount) ?? 0)); case MetricType.Dislikes: return((double)((metricRow?.DislikeCount) ?? 0)); case MetricType.Shares: return((double)((metricRow?.ShareCount) ?? 0)); case MetricType.Comments: return((double)((metricRow?.CommentCount) ?? 0)); case MetricType.ViewTime: return((double)MillisecondsToSeconds((metricRow?.ViewTime) ?? 0)); case MetricType.SubscribersGained: return((double)((metricRow?.SubscribersGained) ?? 0)); case MetricType.SubscribersLost: return((double)((metricRow?.SubscribersLost) ?? 0)); default: throw new ArgumentException($"Invalid metric name: {metricName}"); } }
public async Task <BaseResponseModel> Edit(MetricTypeModel request) { BaseResponseModel response = new BaseResponseModel(); if (request.Validate()) { MetricType metricType = await Load(request.Id, response); if (metricType != null) { metricType.Name = request.Name; metricType.Description = request.Description; await Database.SaveChangesAsync(); response.Message = "Metric type was successfully edited!"; } } else { response.Success = false; response.Message = "Some of the required properties is not present!"; } return(response); }
public async Task <decimal> Get(int id, MetricType type, decimal value) { _logger.LogDebug("Get sensor"); var device = await _currentSensorValues.SetSensorData(id, type, value); if (device == null) { _logger.LogError("Faild to set measurement in cache"); } _logger.LogDebug("Save to elastic"); var client = new Nest.ElasticClient(new Uri(_config.Value.MetricsDatabase)); var now = DateTime.Now; var measurement = new Measument { DeviceId = id.ToString(), Type = MetricType.Temperature, Position = device.Metadata.Location, Timestamp = now, Value = value }; var elasticResult = await client.IndexAsync <Measument>(measurement, s => s.Index("measurement-2017")); if (!elasticResult.IsValid) { _logger.LogError("Failed to save measurement"); } return(device.Metadata.Value ?? 10M); }
public IImmutableDictionary <MetricName, IMetric> GetSample(MetricType typeFilter = MetricType.None) { if (typeFilter.HasFlagFast(MetricType.All)) { return(NoSample); } var filtered = new Dictionary <MetricName, IMetric>(); foreach (var entry in _metrics) { switch (entry.Value) { case GaugeMetric _ when typeFilter.HasFlagFast(MetricType.Gauge): case CounterMetric _ when typeFilter.HasFlagFast(MetricType.Counter): case MeterMetric _ when typeFilter.HasFlagFast(MetricType.Meter): case HistogramMetric _ when typeFilter.HasFlagFast(MetricType.Histogram): case TimerMetric _ when typeFilter.HasFlagFast(MetricType.Timer): continue; default: filtered.Add(entry.Key, entry.Value); break; } } return(filtered.ToImmutableDictionary()); }
public Metric(MetricType metricType, Guid pollId) { TimestampUtc = DateTime.UtcNow; MetricType = metricType; StatusCode = 200; PollId = pollId; }
public void TrackPeripheralMetrics(MetricType metric) { if (!usedMods) { metrics.UpdatePeripheralStats(metric); } }
public Metric(string name, MetricType type, MetricValue value, double sample) { Name = name; Value = value; Sample = sample; Type = type; }
public void StartTimer(MetricType type) { if (this.m_jobContext != null) { (this.m_timers[(int)type] = new Timer()).StartTimer(); } }
public void Add(MetricType type, long elapsedTimeMs) { switch (type) { case MetricType.ExecuteReader: this.Add(ref this.m_executeReaderDurationMs, elapsedTimeMs); break; case MetricType.DataReaderMapping: this.Add(ref this.m_dataReaderMappingDurationMs, elapsedTimeMs); break; case MetricType.Query: this.Add(ref this.m_queryDurationMs, elapsedTimeMs); break; case MetricType.OpenConnection: this.Add(ref this.m_openConnectionDurationMs, elapsedTimeMs); break; case MetricType.DisposeDataReader: this.Add(ref this.m_disposeDataReaderDurationMs, elapsedTimeMs); break; case MetricType.CancelCommand: this.Add(ref this.m_cancelCommandDurationMs, elapsedTimeMs); break; } }
public override object VisitFamily(string name, string help, MetricType type, IEnumerable <IMetric> metrics) { Name = name; Help = help; Type = type; return(base.VisitFamily(name, help, type, metrics)); }
internal string FormattedMetricValue(MetricType type, MetricValue metricValue, double sample) { if (sample < 0 || sample > 1) { throw new ArgumentOutOfRangeException(nameof(sample)); } var metricTypeSpecifier = GetMetricTypeSpecifier(type); var value = metricValue.ToString(); if (string.IsNullOrWhiteSpace(metricTypeSpecifier)) { throw new ArgumentException(nameof(type)); } if (sample < 0 || sample > 1) { throw new ArgumentOutOfRangeException(nameof(sample)); } var format = sample < 1 ? SampledMetricDatagramFormat : MetricDatagramFormat; return(string.Format(cultureInfo, format, value, metricTypeSpecifier, sample)); }
internal void StartTimer(MetricType type) { if (m_jobContext != null) { (m_timers[(int)type] = new Timer()).StartTimer(); } }
internal void UpdatePeripheralStats(MetricType type) { switch (type) { case MetricType.BatterySpawn: ++NumBatsSpawned; break; case MetricType.BatteryRetrieve: ++NumBatsRetrieved; break; case MetricType.EnemySpawned: ++NumEnemiesSpawned; break; case MetricType.EnemyKilled: ++NumEnemiesKilled; break; case MetricType.GrenadeThrown: ++NumGrenadesThrown; break; default: break; } }
public Metric(long id, MetricType type, string code, MetricLevel level) { Id = id; Type = type; Code = code; Level = level; }
public SerializedMetric Serialize <T>( MetricType metricType, string name, T value, double sampleRate = 1.0, string[] tags = null) { var serializedMetric = _serializerHelper.GetOptionalSerializedMetric(); if (serializedMetric == null) { return(null); } var builder = serializedMetric.Builder; var unit = _commandToUnit[metricType]; builder.Append(_prefix); builder.Append(name); builder.Append(':'); builder.AppendFormat(CultureInfo.InvariantCulture, "{0}", value); builder.Append('|'); builder.Append(unit); if (sampleRate != 1.0) { builder.AppendFormat(CultureInfo.InvariantCulture, "|@{0}", sampleRate); } _serializerHelper.AppendTags(builder, tags); return(serializedMetric); }
/// <summary> /// /// </summary> /// <param name="appExe">Full path to test executable</param> /// <param name="metricType">Type of interval measurement</param> /// <param name="scenarioName">Scenario name for reporting</param> /// <param name="processWillExit">true: process exits on its own. False: process does not exit, send close.</param> /// <param name="timeout">Max wait for process to exit</param> /// <param name="measurementDelay">Allowed time for startup window</param> /// <param name="iterations">Number of measured iterations</param> /// <param name="appArgs">optional arguments to test executable</param> /// <param name="logFileName">optional log file. Default is appExe.startup.log</param> /// <param name="workingDir">optional working directory</param> /// <param name="warmup">enables/disables warmup iteration</param> /// <param name="traceName">trace name</param> /// <param name="guiApp">true: app under test is a GUI app, false: console</param> /// <param name="skipProfileIteration">true: skip full results iteration</param> /// <param name="reportJsonPath">path to save report json</param> /// <param name="iterationSetup">command to set up before each iteration</param> /// <param name="setupArgs">arguments of iterationSetup</param> /// <param name="iterationCleanup">command to clean up after each iteration</param> /// <param name="cleanupArgs">arguments of iterationCleanup</param> /// <param name="traceDirectory">Directory to put files in (defaults to current directory)</param> /// <param name="environmentVariables">Environment variables set for test processes (example: var1=value1;var2=value2)</param> /// <param name="innerLoopCommand">Environment variables set for test processes (example: var1=value1;var2=value2)</param> /// <param name="innerLoopCommandArgs">Environment variables set for test processes (example: var1=value1;var2=value2)</param> /// <returns></returns> static int Main(string appExe, MetricType metricType, string scenarioName, string traceName, bool processWillExit = false, int iterations = 5, string iterationSetup = "", string setupArgs = "", string iterationCleanup = "", string cleanupArgs = "", int timeout = 60, int measurementDelay = 15, string appArgs = "", string logFileName = "", string workingDir = "", bool warmup = true, bool guiApp = true, bool skipProfileIteration = true, //This is causing an internal CLR error, doing this to unbock us for now. Tracked by https://github.com/dotnet/performance/issues/1689 string reportJsonPath = "", string traceDirectory = null, string environmentVariables = null, string innerLoopCommand = "", string innerLoopCommandArgs = "" ) { Logger logger = new Logger(String.IsNullOrEmpty(logFileName) ? $"{appExe}.startup.log" : logFileName);
/// <summary> /// Gets the metric with the belonging MetricType /// </summary> /// <param name="type"></param> /// <returns></returns> public IMetric Get(MetricType type) { lock (_metrics) { return(_metrics.FirstOrDefault(m => m.Key == type)); } }
private DataPoint CreateDataPoint(MetricType metricType, string name, double value, string[] tags) { // TODO splunk: consider pooling data points var dataPoint = new DataPoint { metricType = metricType, metric = name, value = new Datum { doubleValue = value }, timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }; dataPoint.dimensions.AddRange(_globalDimensions); if (tags != null) { foreach (var tag in tags) { dataPoint.dimensions.Add(ToDimension(tag)); } } return(dataPoint); }
public static BaseMetric Get(MetricType metricType) { BaseMetric metric = null; switch (metricType) { case MetricType.Accuracy: metric = new Accuracy(); break; case MetricType.MSE: metric = new MSE(); break; case MetricType.MAE: metric = new MAE(); break; case MetricType.MAPE: metric = new MAPE(); break; case MetricType.MSLE: metric = new MSLE(); break; default: break; } return(metric); }
public async Task <BaseResponseModel> Drop(int id) { BaseResponseModel response = new BaseResponseModel(); MetricType metricType = await Load(id, response); if (metricType != null) { if (metricType.Metric.Count == 0) { Database.MetricType.Remove(metricType); await Database.SaveChangesAsync(); response.Message = "Metric type was successfully deleted!"; } else { response.Success = false; response.Message = "Cannot delete metric type, because some metrics use this type!"; } } return(response); }
//Nastavení hodnoty pomocí řetězce. public void Set(string valueString) { IngredientValue i = ParseValue(valueString); this.pType = i.pType; this.pValue = i.pValue; }
/// <summary> /// Creates a new instance of a metric for logs /// </summary> /// <param name="key"></param> /// <param name="title"></param> /// <param name="factory"></param> public LogMetric(MetricType key, string title, Func <object> factory) { Key = key; Title = title; _factory = factory; }
/// <summary> /// Creates a new instance of a metric /// </summary> /// <param name="key"></param> /// <param name="title"></param> /// <param name="value"></param> public Metric(MetricType key, string title, object value) { Key = key; Title = title; Value = value; }
public async Task <BaseResponseModelPost> Create(MetricTypeModel request) { BaseResponseModelPost response = new BaseResponseModelPost(); if (request.Validate()) { MetricType metricType = new MetricType { Name = request.Name, Description = request.Description }; await Database.MetricType.AddAsync(metricType); await Database.SaveChangesAsync(); response.Id = metricType.Id; response.Message = "Metric type was successfully created!"; } else { response.Success = false; response.Message = "Some of the required properties is not present!"; } return(response); }
public Metric(string category, string name, MetricType metricType) { Category = category; MetricType = metricType; Name = name; Occurred = DateTime.UtcNow; IsIncrement = false; Settings = new MetricSetting() { AutoReportZeroIfNothingReported = false }; }
public static Action<StatrContext> WritesDataPoints(string bucketName, MetricType metricType, IEnumerable<DataPoint> points) { return context => { var storageEngine = context.StorageEngine; var writer = storageEngine.GetWriter(new BucketReference(metricType, bucketName)); writer.Write(points); }; }
public static Action<StatrContext> WritesDataPoints(string bucketName, MetricType metricType, params DataPoint[] points) { if (!points.Any()) { points = new[] { new DataPoint(DateTime.Now, 300f, 0) }; } return WritesDataPoints(bucketName, metricType, (IEnumerable<DataPoint>)points); }
public void parsing(string input, string name, string value, MetricType type) { var result = new Metric(); Check.That( () => Metric.TryParse(input, out result), () => result.Name == name, () => result.Value.ToString() == value, () => result.Value.Type == type ); }
public static Action<StatrContext> ReadsDataPoints(string bucketName, MetricType metricType) { return context => { var storageEngine = context.StorageEngine; var reader = storageEngine.GetReader(new BucketReference(metricType, bucketName)); var points = reader.Read(); context.Add(points); }; }
/// <summary> /// Constructor. Called by metrics of numerical types. /// </summary> /// <param name="info">Meta-data for the metric</param> /// <param name="value">The numerical value of the metric. Numerical types can be /// directly type casted to double.</param> /// <param name="typeOfMetric">Type of metric - counter or gauge</param> /// <param name="onVisit">Action to take on receiving <see cref="IMetricsVisitor"/></param> public ImmutableMetricsImpl(IMetricsInfo info, double value, MetricType typeOfMetric, Action<IMetricsVisitor> onVisit) { NumericValue = value; LongValue = null; TypeOfMetric = typeOfMetric; _info = info; _onVisit = onVisit; }
public static Action<StatrContext> Fetches(string bucket, MetricType metricType) { return context => { var query = new Query(bucket, metricType); var queryEngine = context.QueryEngine; var results = queryEngine.Execute(query); context.Add(results.DataPoints); }; }
public void SetupMetric(string metricName, MetricType type) { _counters.AddOrUpdate(metricName, name => new MetricCounter(name, type), (name, existingCounter) => { if (existingCounter.MetricType == type) { return existingCounter; } return new MetricCounter(name, type); }); }
internal static void addValue(MetricType type, long value) { Dictionary<long, int> histogram; if (!data_.TryGetValue(type, out histogram)) { histogram = new Dictionary<long, int>(); data_.Add(type, histogram); histogram.Add(value, 1); return; } if (histogram.ContainsKey(value)) { histogram[value] += 1; } else { histogram.Add(value, 1); } }
private static MeasurementTimeByType CalculateTimeBetweenMetrics(ReleaseWindow releaseWindow, IEnumerable<Metric> metrics, MeasurementType measurementType, MetricType startMetricType, MetricType finishMetricType) { var metricDict = GetMetricTimes(new[] { startMetricType, finishMetricType }, metrics); if (metricDict == null) { Log.WarnFormat("Some metrics are absent. ReleaseId={0}, Metrics={1}", releaseWindow.ExternalId, new[] { startMetricType, finishMetricType }.FormatElements()); return null; } var startMetricTime = metricDict[startMetricType]; var finishMetricTime = metricDict[finishMetricType]; if (finishMetricTime < startMetricTime) throw new ArgumentException(string.Format("{1} time less then {0} time", startMetricType, finishMetricType)); return new MeasurementTimeByType { Type = measurementType, Value = ConvertToMinutes( finishMetricTime.Subtract(startMetricTime).TotalMinutes ) }; }
public Query(string bucketName, MetricType metricType) { BucketName = bucketName; MetricType = metricType; }
public Metric(string name, double value, MetricType type = MetricType.Gauge) { Name = name; Value = value; Type = type; }
public Bucket(string name, MetricType metricType) { Name = name; MetricType = metricType; }
/// <summary> /// Initializes an instance of the Metric class. /// </summary> /// <param name="name">The name of the metrics.</param> /// <param name="metricType">The type of metric.</param> /// <param name="value">The value of the metric.</param> public Metric(String name, MetricType metricType, Int32 value) { Name = name; MetricType = metricType; Values.Add(value); }
public MetricAggregate(string category, string name, MetricType metricType) { Value = 0; Name = name; Category = category; MetricType = metricType; }
public MetricCounter(string name, MetricType type) { _name = name; _metricType = type; _startedAt = DateTime.UtcNow; _count = 0; _sum = 0; }
public Metric GetMetric(Guid releaseWindowId, MetricType metricType) { var releaseWindow = ReleaseWindowRepository.GetSatisfiedBy(x => x.ExternalId == releaseWindowId); if (releaseWindow == null) { throw new ReleaseWindowNotFoundException(releaseWindowId); } if (!releaseWindow.Metrics.Any()) { return null; } var metric = releaseWindow.Metrics.FirstOrDefault(x => x.MetricType == metricType); return metric == null ? null : Mapper.Map<DataMetric, Metric>(metric); }
internal static string printMetric(MetricType metric) { StringBuilder sb = new StringBuilder(); sb.AppendLine(); sb.AppendLine(); sb.AppendLine(); sb.AppendLine(metric.ToString()); Dictionary<long, int> histogram; if (!data_.TryGetValue(metric, out histogram)) { sb.AppendLine("No data collected"); return sb.ToString(); } /* for (Dictionary<long, int>.Enumerator i = histogram.GetEnumerator(); i.MoveNext(); ) { KeyValuePair<long, int> pair = i.Current; sb.Append(pair.Key); sb.Append(": "); sb.AppendLine(pair.Value); } */ List<long> keys = histogram.Keys.ToList<long>(); keys.Sort(); foreach (long key in keys) { sb.Append(key); sb.Append(": "); sb.AppendLine(histogram[key].ToString()); } return sb.ToString(); }
private void CreateMetric(int releaseWindowId, MetricType metricType, DateTime? executedOn = null, Guid? externalId = null) { var metric = new DataMetric { MetricType = metricType, ExternalId = externalId != null && !Guid.Empty.Equals(externalId) ? externalId.Value : Guid.NewGuid(), ReleaseWindowId = releaseWindowId, ExecutedOn = executedOn.HasValue ? executedOn.Value.ToUniversalTime() : (DateTime?)null }; MetricsRepository.Insert(metric); }
private DateTime? GetDefaultExecutedOn(MetricType metricType, ReleaseWindow release) { switch (metricType) { case MetricType.StartTime: return release.StartTime; case MetricType.EndTime: var defaultReleaseWindowDurationTime = ApplicationSettings.DefaultReleaseWindowDurationTime; return release.StartTime.AddMinutes(defaultReleaseWindowDurationTime); } return null; }
/// <summary> /// Initializes a new instance of the <see cref="MetricAttribute"/> by /// using the given metric <paramref name="name"/>. /// </summary> /// <param name="name"> /// A string that should be used to identify a metric. /// </param> /// <param name="type">The metric's type</param> /// <seealso cref="MetricConfig"/> /// <seealso cref="MetricConfig.Name"/> protected MetricAttribute(string name, MetricType type) { Name = name; MetricType = type; }
MetricValue(ulong bits, MetricType type) { this.Bits = bits; this.Type = type; }
internal void Reload(Rainmeter.API api, ref double maxValue) { // Pointers / name this.Name = api.GetMeasureName(); this.Skin = api.GetSkin(); // Measure does the data refresh string reQuery = api.ReadString("ReQuery", string.Empty); if (reQuery.Equals("1") || reQuery.Equals("true", StringComparison.InvariantCultureIgnoreCase)) { this.ReQuery = true; } // Metric Type string type = api.ReadString("MetricType", string.Empty); switch (type.ToLowerInvariant()) { case "memory": case "mem": this.Type = MetricType.TopMemory; break; default: this.Type = MetricType.TopCPU; break; } // If provides data if (this.ReQuery) { this.QueryString = "SELECT * FROM Win32_PerfRawData_PerfProc_Process"; // Apply globally ignored processes to query string globalIgnoredProcesses = api.ReadString("GlobalIgnoredProcesses", string.Empty); if (!string.IsNullOrEmpty(globalIgnoredProcesses)) { bool firstTime = true; foreach (string procName in globalIgnoredProcesses.Split(new char[] { '|' })) { if (firstTime) { this.QueryString += " WHERE"; firstTime = false; } else { this.QueryString += " AND"; } this.QueryString += " NOT Name LIKE '" + procName.Replace("*", "%").Replace("'", "''") + "'"; } } // Create lists only if data provider this._cpuList = new List<Performance>(); this._memList = new List<Performance>(); } // Find the measure in this skin with ReQuery=1 foreach (KeyValuePair<IntPtr, Measure> current in Plugin.Measures) { Measure value = current.Value; if (value.Skin.Equals(this.Skin) && value.ReQuery) { this.DataProvider = current.Key; this.HasData = true; break; } } // Set ignored processes for this measure this.SpecificIgnoredProcesses = api.ReadString("SpecificIgnoredProcesses", string.Empty); // Set format for this measure this.Format = api.ReadString("Format", string.Empty); // Set range or specific process number to display string procNum = api.ReadString("ProcNums", string.Empty); if (!string.IsNullOrEmpty(procNum)) { string[] procNums = procNum.Split(new char[] { '-' }); if (procNums.Length == 1) { int num = Convert.ToInt32(procNums[0]); this.StartProcNum = num; this.EndProcNum = num; } else if (procNums.Length == 2) { this.StartProcNum = Convert.ToInt32(procNums[0]); this.EndProcNum = Convert.ToInt32(procNums[1]); } } }
private static DateTime? GetMetricTime(MetricType type, IEnumerable<Metric> metrics) { var result = GetMetricTimes(new[] { type }, metrics); if (result == null) return null; return result[type]; }