<commit_before>﻿using System;
using Nohros.Extensions;

namespace Nohros.Metrics
{
  /// <summary>
  /// Configuration options for metrics that compute values statistically
  /// through a <see cref="Snapshot"/>.
  /// </summary>
  /// <remarks>
  /// The default <see cref="SnapshotConfig"/> computes the count, min and max.
  /// </remarks>
  /// <seealso cref="Snapshot"/>
  /// <seealso cref="Histogram"/>
  public class SnapshotConfig
  {
    public class Builder
    {
      /// <summary>
      /// Initializes a new instance of the <see cref="Builder"/> class that
      /// builds a <see cref="SnapshotConfig"/> that computes the mean,
      /// standard deviation, min, max and the the 95, 99 and 99.999 by
      /// percentiles by default.
      /// </summary>
      /// <param name="defaults">
      /// A flag indicating if the default values should be set.
      /// </param>
      public Builder(bool defaults = true) {
        if (defaults) {
          ComputeCount = true;
          ComputeMax = true;
          ComputeMin = true;
        }
        Percentiles = new double[0];
      }

      /// <summary>
      /// Initializes a new instance of the <see cref="Builder"/> class by
      /// copying the configuration from the given <paramref name="config"/>.
      /// </summary>
      /// <param name="config"></param>
      public Builder(SnapshotConfig config) {
        Percentiles = config.Percentiles;
        ComputeCount = config.ComputeCount;
        ComputeMax = config.ComputeMax;
        ComputeMean = config.ComputeMean;
        ComputeMedian = config.ComputeMedian;
        ComputeMin = config.ComputeMin;
        ComputeStdDev = config.ComputeStdDev;
      }

      /// <summary>
      /// Defines that the count measure should be computed.
      /// </summary>
      public Builder WithCount(bool enable = true) {
        ComputeMin = enable;
        return this;
      }

      /// <summary>
      /// Defines that the median measure should be computed.
      /// </summary>
      public Builder WithMedian(bool enable = true) {
        ComputeMedian = enable;
        return this;
      }

      /// <summary>
      /// Defines that the max measure should be computed.
      /// </summary>
      public Builder WithMax(bool enable = true) {
        ComputeMax = enable;
        return this;
      }

      /// <summary>
      /// Defines that the min measure should be computed.
      /// </summary>
      public Builder WithMin(bool enable = true) {
        ComputeMin = enable;
        return this;
      }

      /// <summary>
      /// Defines that the mean measure should be computed.
      /// </summary><commit_msg>* WithCount should disable the count stat and not the min.<commit_after>﻿using System;
using Nohros.Extensions;

namespace Nohros.Metrics
{
  /// <summary>
  /// Configuration options for metrics that compute values statistically
  /// through a <see cref="Snapshot"/>.
  /// </summary>
  /// <remarks>
  /// The default <see cref="SnapshotConfig"/> computes the count, min and max.
  /// </remarks>
  /// <seealso cref="Snapshot"/>
  /// <seealso cref="Histogram"/>
  public class SnapshotConfig
  {
    public class Builder
    {
      /// <summary>
      /// Initializes a new instance of the <see cref="Builder"/> class that
      /// builds a <see cref="SnapshotConfig"/> that computes the mean,
      /// standard deviation, min, max and the the 95, 99 and 99.999 by
      /// percentiles by default.
      /// </summary>
      /// <param name="defaults">
      /// A flag indicating if the default values should be set.
      /// </param>
      public Builder(bool defaults = true) {
        if (defaults) {
          ComputeCount = true;
          ComputeMax = true;
          ComputeMin = true;
        }
        Percentiles = new double[0];
      }

      /// <summary>
      /// Initializes a new instance of the <see cref="Builder"/> class by
      /// copying the configuration from the given <paramref name="config"/>.
      /// </summary>
      /// <param name="config"></param>
      public Builder(SnapshotConfig config) {
        Percentiles = config.Percentiles;
        ComputeCount = config.ComputeCount;
        ComputeMax = config.ComputeMax;
        ComputeMean = config.ComputeMean;
        ComputeMedian = config.ComputeMedian;
        ComputeMin = config.ComputeMin;
        ComputeStdDev = config.ComputeStdDev;
      }

      /// <summary>
      /// Defines that the count measure should be computed.
      /// </summary>
      public Builder WithCount(bool enable = true) {
        ComputeCount = enable;
        return this;
      }

      /// <summary>
      /// Defines that the median measure should be computed.
      /// </summary>
      public Builder WithMedian(bool enable = true) {
        ComputeMedian = enable;
        return this;
      }

      /// <summary>
      /// Defines that the max measure should be computed.
      /// </summary>
      public Builder WithMax(bool enable = true) {
        ComputeMax = enable;
        return this;
      }

      /// <summary>
      /// Defines that the min measure should be computed.
      /// </summary>
      public Builder WithMin(bool enable = true) {
        ComputeMin = enable;
        return this;
      }

      /// <summary>
      /// Defines that the mean measure should be computed.
      /// </summary>
{'fraction_non_alphanumeric': 0.12199216564073867, 'fraction_numerical': 0.003730647267300877, 'mean_word_length': 1.9141304347826087, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 63, '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': '3832638', 'n_tokens_mistral': 1441, 'n_tokens_neox': 1410, 'n_words': 469}