<commit_before>defmodule Benchee.Benchmark.Runner do
  @moduledoc """
  This module actually runs our benchmark scenarios, adding information about
  run time and memory usage to each scenario.
  """

  alias Benchee.Benchmark
  alias Benchee.Benchmark.{Scenario, ScenarioContext}
  alias Benchee.Utility.{RepeatN, Parallel}
  alias Benchee.Configuration

  @doc """
  Executes the benchmarks defined before by first running the defined functions
  for `warmup` time without gathering results and them running them for `time`
  gathering their run times.

  This means the total run time of a single benchmarking scenario is warmup +
  time.

  Warmup is usually important for run times with JIT but it seems to have some
  effect on the BEAM as well.

  There will be `parallel` processes spawned executing the benchmark job in
  parallel.
  """
  @spec run_scenarios([Scenario.t], ScenarioContext.t) :: [Scenario.t]
  def run_scenarios(scenarios, scenario_context) do
    {need_to_run, loaded} = Enum.split_with(scenarios, &needs_benchmarking?/1)

    results = Enum.flat_map(need_to_run, fn(scenario) ->
      parallel_benchmark(scenario, scenario_context)
    end)

    results ++ loaded
  end

  # When we load scenarios we mustn't run them again they already have values
  defp needs_benchmarking?(%Scenario{run_times: [_measure | _ments]}), do: false
  defp needs_benchmarking?(_), do: true<commit_msg>partition to still pass on elixir 1.3<commit_after>defmodule Benchee.Benchmark.Runner do
  @moduledoc """
  This module actually runs our benchmark scenarios, adding information about
  run time and memory usage to each scenario.
  """

  alias Benchee.Benchmark
  alias Benchee.Benchmark.{Scenario, ScenarioContext}
  alias Benchee.Utility.{RepeatN, Parallel}
  alias Benchee.Configuration

  @doc """
  Executes the benchmarks defined before by first running the defined functions
  for `warmup` time without gathering results and them running them for `time`
  gathering their run times.

  This means the total run time of a single benchmarking scenario is warmup +
  time.

  Warmup is usually important for run times with JIT but it seems to have some
  effect on the BEAM as well.

  There will be `parallel` processes spawned executing the benchmark job in
  parallel.
  """
  @spec run_scenarios([Scenario.t], ScenarioContext.t) :: [Scenario.t]
  def run_scenarios(scenarios, scenario_context) do
    {need_to_run, loaded} = Enum.partition(scenarios, &needs_benchmarking?/1)

    results = Enum.flat_map(need_to_run, fn(scenario) ->
      parallel_benchmark(scenario, scenario_context)
    end)

    results ++ loaded
  end

  # When we load scenarios we mustn't run them again they already have values
  defp needs_benchmarking?(%Scenario{run_times: [_measure | _ments]}), do: false
  defp needs_benchmarking?(_), do: true
{'fraction_non_alphanumeric': 0.07356564589933122, 'fraction_numerical': 0.0014079549454417458, 'mean_word_length': 4.342105263157895, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1532520', 'n_tokens_mistral': 876, 'n_tokens_neox': 842, 'n_words': 307}