<commit_before>// Copyright (c) 2014, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
//
// NOTE: See also wrapper script sdk/runtime/tools/bmu_benchmark_gallery.sh
//
// Tool to compute bounded mutator utilization (BMU) from a --verbose_gc log.
// Outputs CSV suitable for, e.g., gnuplot:
//
// dart --verbose_gc foo.dart 2> foo.gclog
// dart verbose_gc_to_bmu.dart < foo.gclog > foo.bmu
// gnuplot -p -e "set yr [0:1]; set logscale x; plot 'foo.bmu' with linespoints"

import 'dart:io';
import 'dart:math';

const WINDOW_STEP_FACTOR = 0.9;
const MINIMUM_WINDOW_SIZE_MS = 1;

class Interval<T extends int> {
  T begin;
  T end;
  Interval(this.begin, this.end);
  T get length => max(0, end - begin);
  Interval<T> overlap(Interval<T> other) =>
      new Interval(max(this.begin, other.begin), min(this.end, other.end));
}

class Timeline {
  // Pauses must be added in non-decreasing order of 'begin'.
  void addPause(Interval<int> pause) {
    var last = _pauses.isEmpty ? new Interval<int>(0, 0) : _pauses.last;
    assert(last.begin <= pause.begin);
    // Trim any initial overlap.
    _pauses.add(new Interval(max(pause.begin, last.end), pause.end));
    // TODO(koda): Make VM log actual end time, rather than just last GC end.
    _run.end = max(_run.end, pause.end);
  }

  int get maxWindowSize => _run.length;

  // The windowSize must be no larger than the entire run.<commit_msg>Opt the verbose_gc_to_bmu tool out of null safety.<commit_after>// Copyright (c) 2014, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
//
// NOTE: See also wrapper script sdk/runtime/tools/bmu_benchmark_gallery.sh
//
// Tool to compute bounded mutator utilization (BMU) from a --verbose_gc log.
// Outputs CSV suitable for, e.g., gnuplot:
//
// dart --verbose_gc foo.dart 2> foo.gclog
// dart verbose_gc_to_bmu.dart < foo.gclog > foo.bmu
// gnuplot -p -e "set yr [0:1]; set logscale x; plot 'foo.bmu' with linespoints"
// @dart=2.9

import 'dart:io';
import 'dart:math';

const WINDOW_STEP_FACTOR = 0.9;
const MINIMUM_WINDOW_SIZE_MS = 1;

class Interval<T extends int> {
  T begin;
  T end;
  Interval(this.begin, this.end);
  T get length => max(0, end - begin);
  Interval<T> overlap(Interval<T> other) =>
      new Interval(max(this.begin, other.begin), min(this.end, other.end));
}

class Timeline {
  // Pauses must be added in non-decreasing order of 'begin'.
  void addPause(Interval<int> pause) {
    var last = _pauses.isEmpty ? new Interval<int>(0, 0) : _pauses.last;
    assert(last.begin <= pause.begin);
    // Trim any initial overlap.
    _pauses.add(new Interval(max(pause.begin, last.end), pause.end));
    // TODO(koda): Make VM log actual end time, rather than just last GC end.
    _run.end = max(_run.end, pause.end);
  }

  int get maxWindowSize => _run.length;

  // The windowSize must be no larger than the entire run.
{'fraction_non_alphanumeric': 0.12667946257197696, 'fraction_numerical': 0.008957133717210493, 'mean_word_length': 3.4166666666666665, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 23, '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': '2960465', 'n_tokens_mistral': 1116, 'n_tokens_neox': 1072, 'n_words': 361}