<commit_before>// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Histogram is an object that aggregates statistics, and can summarize them in
// various forms, including ASCII graphical, HTML, and numerically (as a
// vector of numbers corresponding to each of the aggregating buckets).

// It supports calls to accumulate either time intervals (which are processed
// as integral number of milliseconds), or arbitrary integral units.

// The default layout of buckets is exponential.  For example, buckets might
// contain (sequentially) the count of values in the following intervals:
// [0,1), [1,2), [2,4), [4,8), [8,16), [16,32), [32,64), [64,infinity)
// That bucket allocation would actually result from construction of a histogram
// for values between 1 and 64, with 8 buckets, such as:
// Histogram count(L"some name", 1, 64, 8);
// Note that the underflow bucket [0,1) and the overflow bucket [64,infinity)
// are not counted by the constructor in the user supplied "bucket_count"
// argument.
// The above example has an exponential ratio of 2 (doubling the bucket width
// in each consecutive bucket.  The Histogram class automatically calculates
// the smallest ratio that it can use to construct the number of buckets
// selected in the constructor.  An another example, if you had 50 buckets,
// and millisecond time values from 1 to 10000, then the ratio between
// consecutive bucket widths will be approximately somewhere around the 50th
// root of 10000.  This approach provides very fine grain (narrow) buckets
// at the low end of the histogram scale, but allows the histogram to cover a
// gigantic range with the addition of very few buckets.

#ifndef BASE_HISTOGRAM_H__
#define BASE_HISTOGRAM_H__

#include <map>
#include <string>
#include <vector>

#include "base/lock.h"
#include "base/scoped_ptr.h"
#include "base/stats_counters.h"

//------------------------------------------------------------------------------
// Provide easy general purpose histogram in a macro, just like stats counters.
// The first two macros use 50 buckets.

#define HISTOGRAM_TIMES(name, sample) do { \
    static Histogram counter((name), base::TimeDelta::FromMilliseconds(1), \
                             base::TimeDelta::FromSeconds(10), 50); \
    counter.AddTime(sample); \
  } while (0)

#define HISTOGRAM_COUNTS(name, sample) do { \
    static Histogram counter((name), 1, 1000000, 50); \
    counter.Add(sample); \
  } while (0)

// For folks that need real specific times, use this, but you'll only get
// samples that are in the range (overly large samples are discarded).
#define HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) do { \
    static Histogram counter((name), min, max, bucket_count); \
    if ((sample) < (max)) counter.AddTime(sample); \
  } while (0)

//------------------------------------------------------------------------------
// This macro set is for a histogram that can support both addition and removal
// of samples. It should be used to render the accumulated asset allocation
// of some samples.  For example, it can sample memory allocation sizes, and
// memory releases (as negative samples).
// To simplify the interface, only non-zero values can be sampled, with positive
// numbers indicating addition, and negative numbers implying dimunition
// (removal).
// Note that the underlying ThreadSafeHistogram() uses locking to ensure that
// counts are precise (no chance of losing an addition or removal event, due to<commit_msg>Another macro for 100 linear slots - Mirrors same without UMA - Current tests sufice<commit_after>// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Histogram is an object that aggregates statistics, and can summarize them in
// various forms, including ASCII graphical, HTML, and numerically (as a
// vector of numbers corresponding to each of the aggregating buckets).

// It supports calls to accumulate either time intervals (which are processed
// as integral number of milliseconds), or arbitrary integral units.

// The default layout of buckets is exponential.  For example, buckets might
// contain (sequentially) the count of values in the following intervals:
// [0,1), [1,2), [2,4), [4,8), [8,16), [16,32), [32,64), [64,infinity)
// That bucket allocation would actually result from construction of a histogram
// for values between 1 and 64, with 8 buckets, such as:
// Histogram count(L"some name", 1, 64, 8);
// Note that the underflow bucket [0,1) and the overflow bucket [64,infinity)
// are not counted by the constructor in the user supplied "bucket_count"
// argument.
// The above example has an exponential ratio of 2 (doubling the bucket width
// in each consecutive bucket.  The Histogram class automatically calculates
// the smallest ratio that it can use to construct the number of buckets
// selected in the constructor.  An another example, if you had 50 buckets,
// and millisecond time values from 1 to 10000, then the ratio between
// consecutive bucket widths will be approximately somewhere around the 50th
// root of 10000.  This approach provides very fine grain (narrow) buckets
// at the low end of the histogram scale, but allows the histogram to cover a
// gigantic range with the addition of very few buckets.

#ifndef BASE_HISTOGRAM_H__
#define BASE_HISTOGRAM_H__

#include <map>
#include <string>
#include <vector>

#include "base/lock.h"
#include "base/scoped_ptr.h"
#include "base/stats_counters.h"

//------------------------------------------------------------------------------
// Provide easy general purpose histogram in a macro, just like stats counters.
// The first two macros use 50 buckets.

#define HISTOGRAM_TIMES(name, sample) do { \
    static Histogram counter((name), base::TimeDelta::FromMilliseconds(1), \
                             base::TimeDelta::FromSeconds(10), 50); \
    counter.AddTime(sample); \
  } while (0)

#define HISTOGRAM_COUNTS(name, sample) do { \
    static Histogram counter((name), 1, 1000000, 50); \
    counter.Add(sample); \
  } while (0)

#define HISTOGRAM_COUNTS_100(name, sample) do { \
    static Histogram counter((name), 1, 100, 50); \
    counter.Add(sample); \
  } while (0)

// For folks that need real specific times, use this, but you'll only get
// samples that are in the range (overly large samples are discarded).
#define HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) do { \
    static Histogram counter((name), min, max, bucket_count); \
    if ((sample) < (max)) counter.AddTime(sample); \
  } while (0)

//------------------------------------------------------------------------------
// This macro set is for a histogram that can support both addition and removal
// of samples. It should be used to render the accumulated asset allocation
// of some samples.  For example, it can sample memory allocation sizes, and
// memory releases (as negative samples).
// To simplify the interface, only non-zero values can be sampled, with positive
// numbers indicating addition, and negative numbers implying dimunition
// (removal).
// Note that the underlying ThreadSafeHistogram() uses locking to ensure that
// counts are precise (no chance of losing an addition or removal event, due to
{'fraction_non_alphanumeric': 0.12971160295103956, 'fraction_numerical': 0.022401073105298458, 'mean_word_length': 3.1840628507295174, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '4285343', 'n_tokens_mistral': 2106, 'n_tokens_neox': 1890, 'n_words': 938}