Search in sources :

Example 1 with ShortCountsHistogram

use of org.HdrHistogram.ShortCountsHistogram in project rest.li by linkedin.

the class TestLatencyMetric method testShortCountHistorgramOverflow.

@Test
public void testShortCountHistorgramOverflow() {
    ShortCountsHistogram histogram = new ShortCountsHistogram(LatencyMetric.LOWEST_DISCERNIBLE_VALUE, LatencyMetric.HIGHEST_TRACKABLE_VALUE, LatencyMetric.NUMBER_OF_SIGNIFICANT_VALUE_DIGITS);
    for (int i = 0; i < Short.MAX_VALUE; i++) {
        histogram.recordValue(1000);
    }
    IllegalStateException expectedException = null;
    try {
        histogram.recordValue(1000);
    } catch (IllegalStateException e) {
        expectedException = e;
    }
    assertNotNull(expectedException);
}
Also used : ShortCountsHistogram(org.HdrHistogram.ShortCountsHistogram) Test(org.testng.annotations.Test)

Example 2 with ShortCountsHistogram

use of org.HdrHistogram.ShortCountsHistogram in project narchy by automenta.

the class NAR method stats.

/**
 * creates a snapshot statistics object
 * TODO extract a Method Object holding the snapshot stats with the instances created below as its fields
 */
public SortedMap<String, Object> stats() {
    LongSummaryStatistics beliefs = new LongSummaryStatistics();
    LongSummaryStatistics goals = new LongSummaryStatistics();
    LongSummaryStatistics questions = new LongSummaryStatistics();
    LongSummaryStatistics quests = new LongSummaryStatistics();
    Histogram termlinkCount = new Histogram(1);
    Histogram tasklinkCount = new Histogram(1);
    // Frequency complexity = new Frequency();
    HashBag clazz = new HashBag();
    HashBag policy = new HashBag();
    HashBag rootOp = new HashBag();
    ShortCountsHistogram volume = new ShortCountsHistogram(2);
    // AtomicInteger i = new AtomicInteger(0);
    // LongSummaryStatistics termlinksCap = new LongSummaryStatistics();
    // LongSummaryStatistics tasklinksCap = new LongSummaryStatistics();
    SortedMap<String, Object> x = new TreeMap();
    synchronized (exe) {
        concepts().filter(xx -> !(xx instanceof Functor)).forEach(c -> {
            // complexity.addValue(c.complexity());
            volume.recordValue(c.volume());
            rootOp.add(c.op());
            clazz.add(c.getClass().toString());
            ConceptState p = c.state();
            policy.add(p != null ? p.toString() : "null");
            // termlinksCap.accept(c.termlinks().capacity());
            termlinkCount.recordValue(c.termlinks().size());
            // tasklinksCap.accept(c.tasklinks().capacity());
            tasklinkCount.recordValue(c.tasklinks().size());
            beliefs.accept(c.beliefs().size());
            goals.accept(c.goals().size());
            questions.accept(c.questions().size());
            quests.accept(c.quests().size());
        });
        // x.put("time real", new Date());
        if (loop.isRunning()) {
            loop.stats("loop", x);
        }
        x.put("time", time());
        // x.put("term index", terms.summary());
        x.put("concept count", concepts.size());
    }
    x.put("belief count", ((double) beliefs.getSum()));
    x.put("goal count", ((double) goals.getSum()));
    Util.decode(tasklinkCount, "tasklink count", 4, x::put);
    // x.put("tasklink usage", ((double) tasklinkCount.getTotalCount()) / tasklinksCap.getSum());
    x.put("tasklink total", ((double) tasklinkCount.getTotalCount()));
    Util.decode(termlinkCount, "termlink count", 4, x::put);
    // x.put("termlink usage", ((double) termlinkCount.getTotalCount()) / termlinksCap.getSum());
    x.put("termlink total", ((double) termlinkCount.getTotalCount()));
    // DoubleSummaryStatistics pos = new DoubleSummaryStatistics();
    // DoubleSummaryStatistics neg = new DoubleSummaryStatistics();
    // causes.forEach(c -> pos.accept(c.pos()));
    // causes.forEach(c -> neg.accept(c.neg()));
    // x.put("value count", pos.getCount());
    // x.put("value pos mean", pos.getAverage());
    // x.put("value pos min", pos.getMin());
    // x.put("value pos max", pos.getMax());
    // x.put("value neg mean", neg.getAverage());
    // x.put("value neg min", neg.getMin());
    // x.put("value neg max", neg.getMax());
    // x.put("volume mean", volume.);
    // 
    // x.put("termLinksCapacity", termlinksCap);
    // x.put("taskLinksUsed", tasklinksUsed);
    // x.put("taskLinksCapacity", tasklinksCap);
    Util.toMap(policy, "concept state", x::put);
    Util.toMap(rootOp, "concept op", x::put);
    Util.decode(volume, "concept volume", 4, x::put);
    Util.toMap(clazz, "concept class", x::put);
    x.put("term cache (eternal)", Op.cache.summary());
    x.put("term cache (temporal)", Op.cacheTemporal.summary());
    return x;
}
Also used : Atom(nars.term.atom.Atom) Ansi(org.fusesource.jansi.Ansi) GZIPInputStream(java.util.zip.GZIPInputStream) Exec(nars.exe.Exec) ConceptBuilder(nars.concept.util.ConceptBuilder) MutableInteger(jcog.math.MutableInteger) URL(java.net.URL) LoggerFactory(org.slf4j.LoggerFactory) ConceptState(nars.concept.util.ConceptState) Truth(nars.truth.Truth) HashBag(org.eclipse.collections.impl.bag.mutable.HashBag) Op(nars.Op) Topic(jcog.event.Topic) ListTopic(jcog.event.ListTopic) TaskConcept(nars.concept.TaskConcept) TruthFunctions.c2w(nars.truth.TruthFunctions.c2w) Term(nars.term.Term) Longs(com.google.common.primitives.Longs) TriConsumer(jcog.util.TriConsumer) ShortToObjectFunction(org.eclipse.collections.api.block.function.primitive.ShortToObjectFunction) Twin(org.eclipse.collections.api.tuple.Twin) Service(jcog.Service) PreciseTruth(nars.truth.PreciseTruth) Functor.f(nars.term.Functor.f) Util(jcog.Util) BeliefTable(nars.table.BeliefTable) Nullable(org.jetbrains.annotations.Nullable) Stream(java.util.stream.Stream) ConceptIndex(nars.index.term.ConceptIndex) GZIPOutputStream(java.util.zip.GZIPOutputStream) java.util.function(java.util.function) NotNull(org.jetbrains.annotations.NotNull) Operator(nars.concept.Operator) nars.control(nars.control) java.util(java.util) Tense(nars.time.Tense) Prioritized(jcog.pri.Prioritized) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ShortCountsHistogram(org.HdrHistogram.ShortCountsHistogram) ETERNAL(nars.time.Tense.ETERNAL) AtomicReference(java.util.concurrent.atomic.AtomicReference) InvalidTaskException(nars.task.util.InvalidTaskException) nars.$.$(nars.$.$) Pri(jcog.pri.Pri) On(jcog.event.On) Cycles(nars.util.Cycles) Pair(org.eclipse.collections.api.tuple.Pair) Concept(nars.concept.Concept) Time(nars.time.Time) Ansi.ansi(org.fusesource.jansi.Ansi.ansi) NarseseException(nars.Narsese.NarseseException) Logger(org.slf4j.Logger) FasterList(jcog.list.FasterList) Functor(nars.term.Functor) Cycler(jcog.exe.Cycler) ITask(nars.task.ITask) NALTask(nars.task.NALTask) Histogram(org.HdrHistogram.Histogram) ArrayIterator(jcog.util.ArrayIterator) java.io(java.io) Subterms(nars.subterm.Subterms) Atomic(nars.term.atom.Atomic) Termed(nars.term.Termed) Services(jcog.Services) HashBag(org.eclipse.collections.impl.bag.mutable.HashBag) ShortCountsHistogram(org.HdrHistogram.ShortCountsHistogram) Histogram(org.HdrHistogram.Histogram) ShortCountsHistogram(org.HdrHistogram.ShortCountsHistogram) ConceptIndex(nars.index.term.ConceptIndex) Functor(nars.term.Functor) ConceptState(nars.concept.util.ConceptState)

Aggregations

Longs (com.google.common.primitives.Longs)1 java.io (java.io)1 URL (java.net.URL)1 java.util (java.util)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 java.util.function (java.util.function)1 Stream (java.util.stream.Stream)1 GZIPInputStream (java.util.zip.GZIPInputStream)1 GZIPOutputStream (java.util.zip.GZIPOutputStream)1 Service (jcog.Service)1 Services (jcog.Services)1 Util (jcog.Util)1 ListTopic (jcog.event.ListTopic)1 On (jcog.event.On)1 Topic (jcog.event.Topic)1 Cycler (jcog.exe.Cycler)1 FasterList (jcog.list.FasterList)1 MutableInteger (jcog.math.MutableInteger)1 Pri (jcog.pri.Pri)1