本文整理汇总了C#中TimeUnit.ToNanos方法的典型用法代码示例。如果您正苦于以下问题:C# TimeUnit.ToNanos方法的具体用法?C# TimeUnit.ToNanos怎么用?C# TimeUnit.ToNanos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeUnit
的用法示例。
在下文中一共展示了TimeUnit.ToNanos方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ScheduledReporter
/// <summary>
/// Creates a new <see cref="ScheduledReporter"/> instance
/// </summary>
/// <param name="registry">the <see cref="MetricRegistry"/> containing the metrics this reporter will report</param>
/// <param name="name">the reporter's name</param>
/// <param name="filter">the filter for which metrics to report</param>
/// <param name="rateUnit">a unit of time</param>
/// <param name="durationUnit">a unit of time</param>
protected ScheduledReporter(MetricRegistry registry,
string name,
MetricFilter filter,
TimeUnit rateUnit,
TimeUnit durationUnit)
{
this.registry = registry;
this.filter = filter;
this.rateFactor = rateUnit.ToSeconds(1);
this.rateUnit = calculateRateUnit(rateUnit);
this.durationFactor = 1.0 / durationUnit.ToNanos(1);
this.durationUnit = durationUnit.ToString().ToLowerInvariant();
}
示例2: Update
public void Update(long duration, TimeUnit unit)
{
Update(unit.ToNanos(duration));
}
示例3: Rate
/// <summary>
/// Returns the rate in the given units of time.
/// </summary>
public double Rate(TimeUnit rateUnit)
{
var nanos = rateUnit.ToNanos(1);
return _rate * nanos;
}
示例4: EWMA
/// <summary>
/// Create a new EWMA with a specific smoothing constant.
/// </summary>
/// <param name="alpha">The smoothing constant</param>
/// <param name="interval">The expected tick interval</param>
/// <param name="intervalUnit">The time unit of the tick interval</param>
public EWMA(double alpha, long interval, TimeUnit intervalUnit)
{
_interval = intervalUnit.ToNanos(interval);
_alpha = alpha;
}
示例5: Convert
public static long Convert(this TimeUnit timeUnit, long d, TimeUnit u)
{
switch (timeUnit)
{
case TimeUnit.NANOSECONDS:
return u.ToNanos(d);
case TimeUnit.MICROSECONDS:
return u.ToMicros(d);
case TimeUnit.MILLISECONDS:
return u.ToMillis(d);
case TimeUnit.SECONDS:
return u.ToSeconds(d);
case TimeUnit.MINUTES:
return u.ToMinutes(d);
case TimeUnit.HOURS:
return u.ToHours(d);
case TimeUnit.DAYS:
return u.ToDays(d);
}
return d;
}