public static bool Intersects(this ITimeInterval time1, ITimeInterval time2) { return time1 != null && time2 != null && (time1.Contains(time2.From) || time1.Contains(time2.To)); }
protected StreamableRecord( uint id, Guid sourceId, ITimeInterval temporalLocation, ISpatialLocation spatialLocation = null) : base(id, sourceId, temporalLocation, spatialLocation) { }
public void OnDeQueueRequest(ITimeInterval itemInQueue) { itemInQueue.Stop(); long ticks = itemInQueue.Elapsed.Ticks; averageTimeInQueue.AddValue(ticks); averageTimeInAllQueues.AddValue(ticks); totalTimeInAllQueues.IncrementBy(ticks); }
/// <summary>The <see cref="ITimeInterval"/> that <see cref="Contains(ITimeInterval,ITimePoint)"/> all the <see cref="ITimePoint"/>s that both <paramref name="other"/> and <paramref name="me"/> <see cref="Contains(ITimeInterval,ITimePoint)"/>.</summary> public static ITimeInterval IntersectionWith(this ITimeInterval me, ITimeInterval other) { var start = TimePoint.Latest(me.FirstInstant(), other.FirstInstant()); var end = TimePoint.Earliest(me.LastInstant(), other.LastInstant()); if(start.IsAfterOrSameInstantAs(end)) //Detect non-intersecting case. { return NewTimeInterval(start, Duration.Zero); } return NewTimeInterval(start, Duration.Between(start, end)); }
public static ITimeInterval Including(this ITimeInterval value1, ITimeInterval value2) { value1.ValidateNonNull(nameof(value2)); return new TimeInterval( value1.From <= value2.From ? value1.From : value2.From, value1.To >= value2.To ? value1.To : value2.To); }
/// <summary> /// Equals as defined by <see cref="TimeIntervalRelation.TimeIntervalRelation"/> /// and <see cref="TimeIntervalRelation.EQUALS"/>. /// </summary> /// <remarks> /// See the // <a href="http://go.microsoft.com/fwlink/?LinkID=85237">full list of guidelines</a> // and also the guidance for <a href="http://go.microsoft.com/fwlink/?LinkId=85238">operator==</a>. /// </remarks> public bool Equals(ITimeInterval other) { Contract.Ensures(Contract.Result<bool>() == ((other == null) ? false : (TimeIntervalRelation.LeastUncertain(this, other) == TimeIntervalRelation.EQUALS))); return (other != null) && GetType().IsInstanceOfType(other) && (TimeIntervalRelation.LeastUncertain(this, other) == TimeIntervalRelation.EQUALS); }
public Record( uint id, Guid sourceId, ITimeInterval temporalLocation, ISpatialLocation spatialLocation = null) { Id = id; SourceId = sourceId; TemporalLocation = temporalLocation; SpatialLocation = spatialLocation; }
public async static Task<StreamableRecord> Create( uint id, Guid sourceId, ITimeInterval temporalLocation, StreamInfo streamInfo, ISpatialLocation spatialLocation = null) { var record = new StreamableRecord(id, sourceId, temporalLocation, spatialLocation); await record.SetStreamInfo(streamInfo, true); return record; }
public IllegalTimeIntervalException(ITimeInterval ti, DateTime? begin, DateTime? end, string messageKey, Exception innerException) : base( /*ti,*/ messageKey, innerException) { Contract.Requires(ti != null); // Contract.Ensures(Value == ti); // Contract.Ensures(ValueType == ti.getType()); Contract.Ensures(Begin == begin); Contract.Ensures(End == end); Contract.Ensures(Message == messageKey); Contract.Ensures(InnerException == innerException); m_Begin = begin; m_End = end; }
public QueueTrackingStatistic(string queueName) { if (StatisticsCollector.CollectQueueStats) { const CounterStorage storage = CounterStorage.LogAndTable; averageQueueSizeCounter = AverageValueStatistic.FindOrCreate( new StatisticName(StatisticNames.QUEUES_QUEUE_SIZE_AVERAGE_PER_QUEUE, queueName), storage); numEnqueuedRequestsCounter = CounterStatistic.FindOrCreate( new StatisticName(StatisticNames.QUEUES_ENQUEUED_PER_QUEUE, queueName), false, storage); if (TrackExtraStats) { totalExecutionTime = TimeIntervalFactory.CreateTimeInterval(true); averageArrivalRate = FloatValueStatistic.FindOrCreate( new StatisticName(StatisticNames.QUEUES_AVERAGE_ARRIVAL_RATE_PER_QUEUE, queueName), () => { TimeSpan totalTime = totalExecutionTime.Elapsed; if (totalTime.Ticks == 0) return 0; long numReqs = numEnqueuedRequestsCounter.GetCurrentValue(); return (float)((((double)numReqs * (double)TimeSpan.TicksPerSecond)) / (double)totalTime.Ticks); }, storage); } averageTimeInQueue = AverageValueStatistic.FindOrCreate(new StatisticName(StatisticNames.QUEUES_TIME_IN_QUEUE_AVERAGE_MILLIS_PER_QUEUE, queueName), storage); averageTimeInQueue.AddValueConverter(Utils.AverageTicksToMilliSeconds); if (averageTimeInAllQueues == null) { averageTimeInAllQueues = AverageValueStatistic.FindOrCreate(new StatisticName(StatisticNames.QUEUES_TIME_IN_QUEUE_AVERAGE_MILLIS_PER_QUEUE, "AllQueues"), storage); averageTimeInAllQueues.AddValueConverter(Utils.AverageTicksToMilliSeconds); } if (totalTimeInAllQueues == null) { totalTimeInAllQueues = CounterStatistic.FindOrCreate( new StatisticName(StatisticNames.QUEUES_TIME_IN_QUEUE_TOTAL_MILLIS_PER_QUEUE, "AllQueues"), false, storage); totalTimeInAllQueues.AddValueConverter(Utils.TicksToMilliSeconds); } } }
/// <summary> /// Start this callback timer /// </summary> /// <param name="time">Timeout time</param> public void StartTimer(TimeSpan time) { if (time < TimeSpan.Zero) throw new ArgumentOutOfRangeException("time", "The timeout parameter is negative."); timeout = time; if (StatisticsCollector.CollectApplicationRequestsStats) { timeSinceIssued = TimeIntervalFactory.CreateTimeInterval(true); timeSinceIssued.Start(); } TimeSpan firstPeriod = timeout; TimeSpan repeatPeriod = Constants.INFINITE_TIMESPAN; // Single timeout period --> No repeat if (config.ResendOnTimeout && config.MaxResendCount > 0) { firstPeriod = repeatPeriod = timeout.Divide(config.MaxResendCount + 1); } // Start time running DisposeTimer(); timer = new SafeTimer(TimeoutCallback, null, firstPeriod, repeatPeriod); }
/// <summary> /// Keep track of thread statistics, mainly timing, can be created outside the thread to be tracked. /// </summary> /// <param name="threadName">Name used for logging the collected stastistics</param> public ThreadTrackingStatistic(string threadName) { ExecutingCpuCycleTime = new TimeIntervalThreadCycleCounterBased(); ExecutingWallClockTime = TimeIntervalFactory.CreateTimeInterval(true); ProcessingCpuCycleTime = new TimeIntervalThreadCycleCounterBased(); ProcessingWallClockTime = TimeIntervalFactory.CreateTimeInterval(true); NumRequests = 0; firstStart = true; Name = threadName; CounterStorage storage = StatisticsCollector.ReportDetailedThreadTimeTrackingStats ? CounterStorage.LogOnly : CounterStorage.DontStore; CounterStorage aggrCountersStorage = CounterStorage.LogOnly; // 4 direct counters allExecutingCpuCycleTime.Add( FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.THREADS_EXECUTION_TIME_TOTAL_CPU_CYCLES, threadName), () => (float)ExecutingCpuCycleTime.Elapsed.TotalMilliseconds, storage)); allExecutingWallClockTime.Add( FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.THREADS_EXECUTION_TIME_TOTAL_WALL_CLOCK, threadName), () => (float)ExecutingWallClockTime.Elapsed.TotalMilliseconds, storage)); allProcessingCpuCycleTime.Add( FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.THREADS_PROCESSING_TIME_TOTAL_CPU_CYCLES, threadName), () => (float)ProcessingCpuCycleTime.Elapsed.TotalMilliseconds, storage)); allProcessingWallClockTime.Add( FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.THREADS_PROCESSING_TIME_TOTAL_WALL_CLOCK, threadName), () => (float)ProcessingWallClockTime.Elapsed.TotalMilliseconds, storage)); // numRequests allNumProcessedRequests.Add( FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.THREADS_PROCESSED_REQUESTS_PER_THREAD, threadName), () => (float)NumRequests, storage)); // aggregate stats if (totalExecutingCpuCycleTime == null) { totalExecutingCpuCycleTime = FloatValueStatistic.FindOrCreate( new StatisticName(StatisticNames.THREADS_EXECUTION_TIME_AVERAGE_CPU_CYCLES, "AllThreads"), () => CalculateTotalAverage(allExecutingCpuCycleTime, totalNumProcessedRequests), aggrCountersStorage); } if (totalExecutingWallClockTime == null) { totalExecutingWallClockTime = FloatValueStatistic.FindOrCreate( new StatisticName(StatisticNames.THREADS_EXECUTION_TIME_AVERAGE_WALL_CLOCK, "AllThreads"), () => CalculateTotalAverage(allExecutingWallClockTime, totalNumProcessedRequests), aggrCountersStorage); } if (totalProcessingCpuCycleTime == null) { totalProcessingCpuCycleTime = FloatValueStatistic.FindOrCreate( new StatisticName(StatisticNames.THREADS_PROCESSING_TIME_AVERAGE_CPU_CYCLES, "AllThreads"), () => CalculateTotalAverage(allProcessingCpuCycleTime, totalNumProcessedRequests), aggrCountersStorage); } if (totalProcessingWallClockTime == null) { totalProcessingWallClockTime = FloatValueStatistic.FindOrCreate( new StatisticName(StatisticNames.THREADS_PROCESSING_TIME_AVERAGE_WALL_CLOCK, "AllThreads"), () => CalculateTotalAverage(allProcessingWallClockTime, totalNumProcessedRequests), aggrCountersStorage); } if (totalNumProcessedRequests == null) { totalNumProcessedRequests = FloatValueStatistic.FindOrCreate( new StatisticName(StatisticNames.THREADS_PROCESSED_REQUESTS_PER_THREAD, "AllThreads"), () => (float)allNumProcessedRequests.Select(cs => cs.GetCurrentValue()).Sum(), aggrCountersStorage); } if (StatisticsCollector.PerformStageAnalysis) { globalStageAnalyzer.AddTracking(this); } }
public bool DeleteValues(ITimeInterval timeInterval) { return(_point.DeleteValues(timeInterval)); }
public void ReportTimeInterval(string name, ITimeInterval value, TimeUnit resolution) { }
public void Start() { timeInterval = TimeIntervalFactory.CreateTimeInterval(true); timeInterval.Start(); }
/// <summary>True if any <see cref="ITimePoint"/> within <paramref name="other"/> is within <paramref name="me"/></summary> public static bool InterSects(this ITimeInterval me, ITimeInterval other) { return !me.IntersectionWith(other).HasZeroDuration(); }
/// <summary> /// Keep track of thread statistics, mainly timing, can be created outside the thread to be tracked. /// </summary> /// <param name="threadName">Name used for logging the collected stastistics</param> /// <param name="storage"></param> public ThreadTrackingStatistic(string threadName) { ExecutingCpuCycleTime = new TimeIntervalThreadCycleCounterBased(); ExecutingWallClockTime = TimeIntervalFactory.CreateTimeInterval(true); ProcessingCpuCycleTime = new TimeIntervalThreadCycleCounterBased(); ProcessingWallClockTime = TimeIntervalFactory.CreateTimeInterval(true); NumRequests = 0; firstStart = true; Name = threadName; CounterStorage storage = StatisticsCollector.ReportDetailedThreadTimeTrackingStats ? CounterStorage.LogOnly : CounterStorage.DontStore; CounterStorage aggrCountersStorage = CounterStorage.LogOnly; // 4 direct counters allExecutingCpuCycleTime.Add( FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.THREADS_EXECUTION_TIME_TOTAL_CPU_CYCLES, threadName), () => (float)ExecutingCpuCycleTime.Elapsed.TotalMilliseconds, storage)); allExecutingWallClockTime.Add( FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.THREADS_EXECUTION_TIME_TOTAL_WALL_CLOCK, threadName), () => (float)ExecutingWallClockTime.Elapsed.TotalMilliseconds, storage)); allProcessingCpuCycleTime.Add( FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.THREADS_PROCESSING_TIME_TOTAL_CPU_CYCLES, threadName), () => (float)ProcessingCpuCycleTime.Elapsed.TotalMilliseconds, storage)); allProcessingWallClockTime.Add( FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.THREADS_PROCESSING_TIME_TOTAL_WALL_CLOCK, threadName), () => (float)ProcessingWallClockTime.Elapsed.TotalMilliseconds, storage)); // numRequests allNumProcessedRequests.Add( FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.THREADS_PROCESSED_REQUESTS_PER_THREAD, threadName), () => (float)NumRequests, storage)); // aggregate stats if (totalExecutingCpuCycleTime == null) { totalExecutingCpuCycleTime = FloatValueStatistic.FindOrCreate( new StatisticName(StatisticNames.THREADS_EXECUTION_TIME_AVERAGE_CPU_CYCLES, "AllThreads"), () => CalculateTotalAverage(allExecutingCpuCycleTime, totalNumProcessedRequests), aggrCountersStorage); } if (totalExecutingWallClockTime == null) { totalExecutingWallClockTime = FloatValueStatistic.FindOrCreate( new StatisticName(StatisticNames.THREADS_EXECUTION_TIME_AVERAGE_WALL_CLOCK, "AllThreads"), () => CalculateTotalAverage(allExecutingWallClockTime, totalNumProcessedRequests), aggrCountersStorage); } if (totalProcessingCpuCycleTime == null) { totalProcessingCpuCycleTime = FloatValueStatistic.FindOrCreate( new StatisticName(StatisticNames.THREADS_PROCESSING_TIME_AVERAGE_CPU_CYCLES, "AllThreads"), () => CalculateTotalAverage(allProcessingCpuCycleTime, totalNumProcessedRequests), aggrCountersStorage); } if (totalProcessingWallClockTime == null) { totalProcessingWallClockTime = FloatValueStatistic.FindOrCreate( new StatisticName(StatisticNames.THREADS_PROCESSING_TIME_AVERAGE_WALL_CLOCK, "AllThreads"), () => CalculateTotalAverage(allProcessingWallClockTime, totalNumProcessedRequests), aggrCountersStorage); } if (totalNumProcessedRequests == null) { totalNumProcessedRequests = FloatValueStatistic.FindOrCreate( new StatisticName(StatisticNames.THREADS_PROCESSED_REQUESTS_PER_THREAD, "AllThreads"), () => (float)allNumProcessedRequests.Select(cs => cs.GetCurrentValue()).Sum(), aggrCountersStorage); } if (StatisticsCollector.PerformStageAnalysis) globalStageAnalyzer.AddTracking(this); }
/// <summary>True if <paramref name="me"/> contains every <see cref="ITimePoint"/> that <paramref name="other"/> contains</summary> public static bool Contains(this ITimeInterval me, ITimeInterval other) { return me.Contains(other.FirstInstant()) && me.Contains(other.LastInstant()); }
/// <summary>The last <see cref="ITimePoint"/> before <paramref name="me"/> that is not part of the interval.<paramref name="me"/></summary> public static ITimePoint LastInstantBefore(this ITimeInterval me) { return(me.FirstInstant().PreviousInstant()); }
/// <summary>The first <see cref="ITimePoint"/> that the <see cref="ITimeInterval"/> <see cref="Contains(ITimeInterval,ITimePoint)"/> (Given that the interval has non-zero duration, othervise it contains no points and this point is simply its location in time..)</summary> public static ITimePoint FirstInstant(this ITimeInterval me) { return(me.TimePosition); }
protected virtual void OnTemporalLocationChanged(ITimeInterval oldValue, ITimeInterval newValue) { TemporalLocationChanged.RaiseEvent(this, () => new ValueChangeEventArgs<ITimeInterval>(oldValue, newValue)); }
public void AddInterval(string name, ITimeInterval interval) { this.AddIntervals(name); this.intervals[name].Add(interval); }
public List <IPointValue> RecordedValues(ITimeInterval timeInterval, PointBoundaryType pointBoundaryType) { return(RecordedValues(timeInterval.DateTimeStart, timeInterval.DateTimeEnd, pointBoundaryType)); }
public bool Equals(ITimeInterval other) { return (other != null) && (GetHashCode().Equals(other.GetHashCode())); }
public void OnEnQueueRequest(int numEnqueuedRequests, int queueLength, ITimeInterval itemInQueue) { numEnqueuedRequestsCounter.IncrementBy(numEnqueuedRequests); averageQueueSizeCounter.AddValue(queueLength); itemInQueue.Start(); }