本文整理汇总了C#中Histogram.recordValue方法的典型用法代码示例。如果您正苦于以下问题:C# Histogram.recordValue方法的具体用法?C# Histogram.recordValue怎么用?C# Histogram.recordValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Histogram
的用法示例。
在下文中一共展示了Histogram.recordValue方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HistogramDataAccessTest
static HistogramDataAccessTest()
{
histogram = new Histogram(highestTrackableValue, numberOfSignificantValueDigits);
scaledHistogram = new Histogram(1000, highestTrackableValue * 512, numberOfSignificantValueDigits);
rawHistogram = new Histogram(highestTrackableValue, numberOfSignificantValueDigits);
scaledRawHistogram = new Histogram(1000, highestTrackableValue * 512, numberOfSignificantValueDigits);
// Log hypothetical scenario: 100 seconds of "perfect" 1msec results, sampled
// 100 times per second (10,000 results), followed by a 100 second pause with
// a single (100 second) recorded result. Recording is done indicating an expected
// interval between samples of 10 msec:
for (int i = 0; i < 10000; i++)
{
histogram.recordValueWithExpectedInterval(1000 /* 1 msec */, 10000 /* 10 msec expected interval */);
scaledHistogram.recordValueWithExpectedInterval(1000 * 512 /* 1 msec */, 10000 * 512 /* 10 msec expected interval */);
rawHistogram.recordValue(1000 /* 1 msec */);
scaledRawHistogram.recordValue(1000 * 512/* 1 msec */);
}
histogram.recordValueWithExpectedInterval(100000000L /* 100 sec */, 10000 /* 10 msec expected interval */);
scaledHistogram.recordValueWithExpectedInterval(100000000L * 512 /* 100 sec */, 10000 * 512 /* 10 msec expected interval */);
rawHistogram.recordValue(100000000L /* 100 sec */);
scaledRawHistogram.recordValue(100000000L * 512 /* 100 sec */);
postCorrectedHistogram = rawHistogram.copyCorrectedForCoordinatedOmission(10000 /* 10 msec expected interval */);
postCorrectedScaledHistogram = scaledRawHistogram.copyCorrectedForCoordinatedOmission(10000 * 512 /* 10 msec expected interval */);
}
示例2: testHistogramEncodingFullRangeOfValues
public void testHistogramEncodingFullRangeOfValues() //throws Exception
{
Histogram histogram = new Histogram(highestTrackableValue, 3);
for (long i = 0; i < highestTrackableValue; i += 100)
{
histogram.recordValue(i);
}
histogram.recordValue(highestTrackableValue);
Console.WriteLine("\n\nTesting encoding of a Histogram (long):");
var targetBuffer = ByteBuffer.allocate(histogram.getNeededByteBufferCapacity());
histogram.encodeIntoByteBuffer(targetBuffer);
targetBuffer.rewind();
Histogram histogram2 = Histogram.decodeFromByteBuffer(targetBuffer, 0);
Assert.assertEquals(histogram, histogram2);
var targetCompressedBuffer = ByteBuffer.allocate(histogram.getNeededByteBufferCapacity());
histogram.encodeIntoCompressedByteBuffer(targetCompressedBuffer);
targetCompressedBuffer.rewind();
Histogram histogram3 = Histogram.decodeFromCompressedByteBuffer(targetCompressedBuffer, 0);
Assert.assertEquals(histogram, histogram3);
Console.WriteLine();
histogram3.outputPercentileDistribution(Console.Out);
}
示例3: testGetValueAtPercentileForLargeHistogram
public void testGetValueAtPercentileForLargeHistogram()
{
long largestValue = 1000000000000L;
Histogram h = new Histogram(largestValue, 5);
h.recordValue(largestValue);
Assert.assertTrue(h.getValueAtPercentile(100.0) > 0);
}
示例4: testCopyInto
public void testCopyInto()
{
Histogram histogram = new Histogram(highestTrackableValue, numberOfSignificantValueDigits);
Histogram targetHistogram = new Histogram(highestTrackableValue, numberOfSignificantValueDigits);
histogram.recordValue(testValueLevel);
histogram.recordValue(testValueLevel * 10);
histogram.recordValueWithExpectedInterval(histogram.getHighestTrackableValue() - 1, 31000);
Console.WriteLine("Testing copyInto for Histogram:");
histogram.copyInto(targetHistogram);
assertEqual(histogram, targetHistogram);
histogram.recordValue(testValueLevel * 20);
histogram.copyInto(targetHistogram);
assertEqual(histogram, targetHistogram);
IntHistogram intHistogram = new IntHistogram(highestTrackableValue, numberOfSignificantValueDigits);
IntHistogram targetIntHistogram = new IntHistogram(highestTrackableValue, numberOfSignificantValueDigits);
intHistogram.recordValue(testValueLevel);
intHistogram.recordValue(testValueLevel * 10);
intHistogram.recordValueWithExpectedInterval(intHistogram.getHighestTrackableValue() - 1, 31000);
Console.WriteLine("Testing copyInto for IntHistogram:");
intHistogram.copyInto(targetIntHistogram);
assertEqual(intHistogram, targetIntHistogram);
intHistogram.recordValue(testValueLevel * 20);
intHistogram.copyInto(targetIntHistogram);
assertEqual(intHistogram, targetIntHistogram);
ShortHistogram shortHistogram = new ShortHistogram(highestTrackableValue, numberOfSignificantValueDigits);
ShortHistogram targetShortHistogram = new ShortHistogram(highestTrackableValue, numberOfSignificantValueDigits);
shortHistogram.recordValue(testValueLevel);
shortHistogram.recordValue(testValueLevel * 10);
shortHistogram.recordValueWithExpectedInterval(shortHistogram.getHighestTrackableValue() - 1, 31000);
Console.WriteLine("Testing copyInto for ShortHistogram:");
shortHistogram.copyInto(targetShortHistogram);
assertEqual(shortHistogram, targetShortHistogram);
shortHistogram.recordValue(testValueLevel * 20);
shortHistogram.copyInto(targetShortHistogram);
assertEqual(shortHistogram, targetShortHistogram);
AtomicHistogram atomicHistogram = new AtomicHistogram(highestTrackableValue, numberOfSignificantValueDigits);
AtomicHistogram targetAtomicHistogram = new AtomicHistogram(highestTrackableValue, numberOfSignificantValueDigits);
atomicHistogram.recordValue(testValueLevel);
atomicHistogram.recordValue(testValueLevel * 10);
atomicHistogram.recordValueWithExpectedInterval(atomicHistogram.getHighestTrackableValue() - 1, 31000);
Console.WriteLine("Testing copyInto for AtomicHistogram:");
atomicHistogram.copyInto(targetAtomicHistogram);
assertEqual(atomicHistogram, targetAtomicHistogram);
atomicHistogram.recordValue(testValueLevel * 20);
atomicHistogram.copyInto(targetAtomicHistogram);
assertEqual(atomicHistogram, targetAtomicHistogram);
SynchronizedHistogram syncHistogram = new SynchronizedHistogram(highestTrackableValue, numberOfSignificantValueDigits);
SynchronizedHistogram targetSyncHistogram = new SynchronizedHistogram(highestTrackableValue, numberOfSignificantValueDigits);
syncHistogram.recordValue(testValueLevel);
syncHistogram.recordValue(testValueLevel * 10);
syncHistogram.recordValueWithExpectedInterval(syncHistogram.getHighestTrackableValue() - 1, 31000); // Should this really be 31, if it is the test takes 1min!!!);
Console.WriteLine("Testing copyInto for SynchronizedHistogram:");
syncHistogram.copyInto(targetSyncHistogram);
assertEqual(syncHistogram, targetSyncHistogram);
syncHistogram.recordValue(testValueLevel * 20);
syncHistogram.copyInto(targetSyncHistogram);
assertEqual(syncHistogram, targetSyncHistogram);
}
示例5: testScaledCopyInto
public void testScaledCopyInto()
{
Histogram histogram = new Histogram(1000, highestTrackableValue, numberOfSignificantValueDigits);
Histogram targetHistogram = new Histogram(1000, highestTrackableValue, numberOfSignificantValueDigits);
histogram.recordValue(testValueLevel);
histogram.recordValue(testValueLevel * 10);
histogram.recordValueWithExpectedInterval(histogram.getHighestTrackableValue() - 1, 31000);
Console.WriteLine("Testing copyInto for scaled Histogram:");
histogram.copyInto(targetHistogram);
assertEqual(histogram, targetHistogram);
histogram.recordValue(testValueLevel * 20);
histogram.copyInto(targetHistogram);
assertEqual(histogram, targetHistogram);
IntHistogram intHistogram = new IntHistogram(1000, highestTrackableValue, numberOfSignificantValueDigits);
IntHistogram targetIntHistogram = new IntHistogram(1000, highestTrackableValue, numberOfSignificantValueDigits);
intHistogram.recordValue(testValueLevel);
intHistogram.recordValue(testValueLevel * 10);
intHistogram.recordValueWithExpectedInterval(intHistogram.getHighestTrackableValue() - 1, 31000);
Console.WriteLine("Testing copyInto for scaled IntHistogram:");
intHistogram.copyInto(targetIntHistogram);
assertEqual(intHistogram, targetIntHistogram);
intHistogram.recordValue(testValueLevel * 20);
intHistogram.copyInto(targetIntHistogram);
assertEqual(intHistogram, targetIntHistogram);
ShortHistogram shortHistogram = new ShortHistogram(1000, highestTrackableValue, numberOfSignificantValueDigits);
ShortHistogram targetShortHistogram = new ShortHistogram(1000, highestTrackableValue, numberOfSignificantValueDigits);
shortHistogram.recordValue(testValueLevel);
shortHistogram.recordValue(testValueLevel * 10);
shortHistogram.recordValueWithExpectedInterval(shortHistogram.getHighestTrackableValue() - 1, 31000);
Console.WriteLine("Testing copyInto for scaled ShortHistogram:");
shortHistogram.copyInto(targetShortHistogram);
assertEqual(shortHistogram, targetShortHistogram);
shortHistogram.recordValue(testValueLevel * 20);
shortHistogram.copyInto(targetShortHistogram);
assertEqual(shortHistogram, targetShortHistogram);
AtomicHistogram atomicHistogram = new AtomicHistogram(1000, highestTrackableValue, numberOfSignificantValueDigits);
AtomicHistogram targetAtomicHistogram = new AtomicHistogram(1000, highestTrackableValue, numberOfSignificantValueDigits);
atomicHistogram.recordValue(testValueLevel);
atomicHistogram.recordValue(testValueLevel * 10);
atomicHistogram.recordValueWithExpectedInterval(atomicHistogram.getHighestTrackableValue() - 1, 31000);
atomicHistogram.copyInto(targetAtomicHistogram);
assertEqual(atomicHistogram, targetAtomicHistogram);
atomicHistogram.recordValue(testValueLevel * 20);
Console.WriteLine("Testing copyInto for scaled AtomicHistogram:");
atomicHistogram.copyInto(targetAtomicHistogram);
assertEqual(atomicHistogram, targetAtomicHistogram);
SynchronizedHistogram syncHistogram = new SynchronizedHistogram(1000, highestTrackableValue, numberOfSignificantValueDigits);
SynchronizedHistogram targetSyncHistogram = new SynchronizedHistogram(1000, highestTrackableValue, numberOfSignificantValueDigits);
syncHistogram.recordValue(testValueLevel);
syncHistogram.recordValue(testValueLevel * 10);
syncHistogram.recordValueWithExpectedInterval(syncHistogram.getHighestTrackableValue() - 1, 31000);
Console.WriteLine("Testing copyInto for scaled SynchronizedHistogram:");
syncHistogram.copyInto(targetSyncHistogram);
assertEqual(syncHistogram, targetSyncHistogram);
syncHistogram.recordValue(testValueLevel * 20);
syncHistogram.copyInto(targetSyncHistogram);
assertEqual(syncHistogram, targetSyncHistogram);
}
示例6: testCopy
public void testCopy()
{
Histogram histogram = new Histogram(highestTrackableValue, numberOfSignificantValueDigits);
histogram.recordValue(testValueLevel);
histogram.recordValue(testValueLevel * 10);
histogram.recordValueWithExpectedInterval(histogram.getHighestTrackableValue() - 1, 31000);
Console.WriteLine("Testing copy of Histogram:");
assertEqual(histogram, histogram.copy());
IntHistogram intHistogram = new IntHistogram(highestTrackableValue, numberOfSignificantValueDigits);
intHistogram.recordValue(testValueLevel);
intHistogram.recordValue(testValueLevel * 10);
intHistogram.recordValueWithExpectedInterval(intHistogram.getHighestTrackableValue() - 1, 31000);
Console.WriteLine("Testing copy of IntHistogram:");
assertEqual(intHistogram, intHistogram.copy());
ShortHistogram shortHistogram = new ShortHistogram(highestTrackableValue, numberOfSignificantValueDigits);
shortHistogram.recordValue(testValueLevel);
shortHistogram.recordValue(testValueLevel * 10);
shortHistogram.recordValueWithExpectedInterval(shortHistogram.getHighestTrackableValue() - 1, 31000);
Console.WriteLine("Testing copy of ShortHistogram:");
assertEqual(shortHistogram, shortHistogram.copy());
AtomicHistogram atomicHistogram = new AtomicHistogram(highestTrackableValue, numberOfSignificantValueDigits);
atomicHistogram.recordValue(testValueLevel);
atomicHistogram.recordValue(testValueLevel * 10);
atomicHistogram.recordValueWithExpectedInterval(atomicHistogram.getHighestTrackableValue() - 1, 31000);
Console.WriteLine("Testing copy of AtomicHistogram:");
assertEqual(atomicHistogram, atomicHistogram.copy());
SynchronizedHistogram syncHistogram = new SynchronizedHistogram(highestTrackableValue, numberOfSignificantValueDigits);
syncHistogram.recordValue(testValueLevel);
syncHistogram.recordValue(testValueLevel * 10);
syncHistogram.recordValueWithExpectedInterval(syncHistogram.getHighestTrackableValue() - 1, 31000);
Console.WriteLine("Testing copy of SynchronizedHistogram:");
assertEqual(syncHistogram, syncHistogram.copy());
}
示例7: testAdd
public void testAdd()
{
Histogram histogram = new Histogram(highestTrackableValue, numberOfSignificantValueDigits);
Histogram other = new Histogram(highestTrackableValue, numberOfSignificantValueDigits);
histogram.recordValue(testValueLevel);
histogram.recordValue(testValueLevel * 1000);
other.recordValue(testValueLevel);
other.recordValue(testValueLevel * 1000);
histogram.add(other);
Assert.assertEquals(2L, histogram.getCountAtValue(testValueLevel));
Assert.assertEquals(2L, histogram.getCountAtValue(testValueLevel * 1000));
Assert.assertEquals(4L, histogram.getTotalCount());
Histogram biggerOther = new Histogram(highestTrackableValue * 2, numberOfSignificantValueDigits);
biggerOther.recordValue(testValueLevel);
biggerOther.recordValue(testValueLevel * 1000);
// Adding the smaller histogram to the bigger one should work:
biggerOther.add(histogram);
Assert.assertEquals(3L, biggerOther.getCountAtValue(testValueLevel));
Assert.assertEquals(3L, biggerOther.getCountAtValue(testValueLevel * 1000));
Assert.assertEquals(6L, biggerOther.getTotalCount());
// But trying to add a larger histogram into a smaller one should throw an AIOOB:
bool thrown = false;
try
{
// This should throw:
histogram.add(biggerOther);
}
catch (ArgumentOutOfRangeException)
{
thrown = true;
}
Assert.assertTrue(thrown);
}
示例8: testReset
public void testReset()
{
Histogram histogram = new Histogram(highestTrackableValue, numberOfSignificantValueDigits);
histogram.recordValue(testValueLevel);
histogram.reset();
Assert.assertEquals(0L, histogram.getCountAtValue(testValueLevel));
Assert.assertEquals(0L, histogram.getTotalCount());
}
示例9: testRecordValueWithExpectedInterval
public void testRecordValueWithExpectedInterval()
{
Histogram histogram = new Histogram(highestTrackableValue, numberOfSignificantValueDigits);
histogram.recordValueWithExpectedInterval(testValueLevel, testValueLevel/4);
Histogram rawHistogram = new Histogram(highestTrackableValue, numberOfSignificantValueDigits);
rawHistogram.recordValue(testValueLevel);
// The data will include corrected samples:
Assert.assertEquals(1L, histogram.getCountAtValue((testValueLevel * 1 )/4));
Assert.assertEquals(1L, histogram.getCountAtValue((testValueLevel * 2 )/4));
Assert.assertEquals(1L, histogram.getCountAtValue((testValueLevel * 3 )/4));
Assert.assertEquals(1L, histogram.getCountAtValue((testValueLevel * 4 )/4));
Assert.assertEquals(4L, histogram.getTotalCount());
// But the raw data will not:
Assert.assertEquals(0L, rawHistogram.getCountAtValue((testValueLevel * 1 )/4));
Assert.assertEquals(0L, rawHistogram.getCountAtValue((testValueLevel * 2 )/4));
Assert.assertEquals(0L, rawHistogram.getCountAtValue((testValueLevel * 3 )/4));
Assert.assertEquals(1L, rawHistogram.getCountAtValue((testValueLevel * 4 )/4));
Assert.assertEquals(1L, rawHistogram.getTotalCount());
}
示例10: testRecordValue_Overflow_ShouldThrowException
public void testRecordValue_Overflow_ShouldThrowException()
{
Histogram histogram = new Histogram(highestTrackableValue, numberOfSignificantValueDigits);
histogram.recordValue(highestTrackableValue * 3);
}