<commit_before>// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0

package org.terasology.engine.rendering.nui.layers.ingame.metrics;

import io.micrometer.core.instrument.distribution.HistogramSnapshot;
import io.micrometer.core.instrument.search.Search;
import org.terasology.engine.monitoring.DisplayMetricsMonitor;

import java.util.concurrent.TimeUnit;

final class RunningThreadsMode extends MetricsMode implements AutoCloseable {

     RunningThreadsMode() {
        super("\n- Task Metrics -");
    }

    @Override
    public String getMetrics() {

        StringBuilder builder = new StringBuilder();
        builder.append(getName());
        builder.append("\n");

        Search.in(DisplayMetricsMonitor.metricRegistry)
                .tag("monitor","display-metric")
                .timers().forEach(k -> {

            HistogramSnapshot snapshot = k.takeSnapshot();
            long count = snapshot.count();

            if (count > 0) {
                double throughput = (count / (double) DisplayMetricsMonitor.captureDuration.toMillis());
                builder.append(k.getId().getName());
                builder.append(" : ");
                builder.append(" throughput: ");
                builder.append(Double.isNaN(throughput) ? "NAN" : String.format("%,10.4f", throughput)).append(" /s");
                builder.append(" mean: ").append(String.format("%,10.4f", k.mean(TimeUnit.MILLISECONDS))).append(" ms");
                builder.append(" max: ").append(String.format("%,10.4f", k.max(TimeUnit.MILLISECONDS))).append(" ms");
                builder.append("\n");
            }
        });
        return builder.toString();
    }

    @Override
    public boolean isAvailable() {
        return true;
    }

    @Override
    public boolean isPerformanceManagerMode() {
        return false;
    }

    @Override
    public void close() throws Exception {

    }
}<commit_msg>Revert "chore: remove empty snapshots"<commit_after>// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0

package org.terasology.engine.rendering.nui.layers.ingame.metrics;

import io.micrometer.core.instrument.distribution.HistogramSnapshot;
import io.micrometer.core.instrument.search.Search;
import org.terasology.engine.monitoring.DisplayMetricsMonitor;

import java.util.concurrent.TimeUnit;

final class RunningThreadsMode extends MetricsMode implements AutoCloseable {

     RunningThreadsMode() {
        super("\n- Task Metrics -");
    }

    @Override
    public String getMetrics() {

        StringBuilder builder = new StringBuilder();
        builder.append(getName());
        builder.append("\n");

        Search.in(DisplayMetricsMonitor.metricRegistry)
                .tag("monitor","display-metric")
                .timers().forEach(k -> {

            HistogramSnapshot snapshot = k.takeSnapshot();
            long count = snapshot.count();
            double throughput = (count / (double) DisplayMetricsMonitor.captureDuration.toMillis());
            builder.append(k.getId().getName());
            builder.append(" : ");
            builder.append(" throughput: ");
            builder.append(Double.isNaN(throughput) ? "NAN" : String.format("%,10.4f", throughput)).append(" /s");
            builder.append(" mean: ").append(String.format("%,10.4f",k.mean(TimeUnit.MILLISECONDS))).append(" ms");
            builder.append(" max: ").append(String.format("%,10.4f",k.max(TimeUnit.MILLISECONDS))).append(" ms");

            builder.append("\n");
        });
        return builder.toString();
    }

    @Override
    public boolean isAvailable() {
        return true;
    }

    @Override
    public boolean isPerformanceManagerMode() {
        return false;
    }

    @Override
    public void close() throws Exception {

    }
}
{'fraction_non_alphanumeric': 0.13555787278415016, 'fraction_numerical': 0.00808133472367049, 'mean_word_length': 2.657769304099142, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4269685', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1020, 'n_words': 191}