<commit_before>require_relative 'job_test'

module TestRunner
  def self.non_blocking(num_of_cycles)
    num_of_cycles.times do |n|
       JobTestFast.new.perform_async('NONBLOCKING', n)
    end
  end

  def self.blocking(num_of_cycles)
    num_of_cycles.times do |n|
      JobTestSlow.new.perform_async('BLOCKING', n)
    end
  end

  def self.thread_killer(num_of_cycles)
    num_of_cycles.times do |n|
      ThreadKiller.new.perform_async('Kill', n)
    end
  end

  def self.large_arg(num_of_cycles)
    arg = Array.new(10000, 'string')

    num_of_cycles.times do |n|
      LargeArg.new.perform_async(arg, n)
    end
  end

  def self.sort_array(num_of_cycles, array_size)
    unsorted_array = (0..array_size).to_a.shuffle

    num_of_cycles.times do |n|
      HeavyCalculation.new.perform_async(n, unsorted_array)
    end
  end

  def self.many_args(num_of_cycles)
    num_of_cycles.times do |n|
      ManyArgs.new.perform_async(n, [1, 2, 3], { key: 'value'}, :symb, 'string', 22, false)
    end
  end

  def self.calculate_primes(num_of_cycles)
    num_of_cycles.times do |n|
      GetPrimes.new.perform_async(n, 10)
    end
  end
end

pids = (1..10).to_a.map do
  fork do
    TestRunner.blocking(5_000)
    exit
  end
end

pids.each { |pid| Process.wait(pid) }<commit_msg>update test enqueueing to enqueue in multiple queues<commit_after>require_relative 'job_test'

module TestRunner
  def self.non_blocking(num_of_cycles)
    num_of_cycles.times do |n|
       JobTestFast.new.perform_async('NONBLOCKING', n)
    end
  end

  def self.blocking(num_of_cycles)
    num_of_cycles.times do |n|
      JobTestSlow.new.perform_async('BLOCKING', n)
    end
  end

  def self.thread_killer(num_of_cycles)
    num_of_cycles.times do |n|
      ThreadKiller.new.perform_async('Kill', n)
    end
  end

  def self.large_arg(num_of_cycles)
    arg = Array.new(10000, 'string')

    num_of_cycles.times do |n|
      LargeArg.new.perform_async(arg, n)
    end
  end

  def self.sort_array(num_of_cycles, array_size)
    unsorted_array = (0..array_size).to_a.shuffle

    num_of_cycles.times do |n|
      HeavyCalculation.new.perform_async(n, unsorted_array)
    end
  end

  def self.many_args(num_of_cycles)
    num_of_cycles.times do |n|
      ManyArgs.new.perform_async(n, [1, 2, 3], { key: 'value'}, :symb, 'string', 22, false)
    end
  end

  def self.calculate_primes(num_of_cycles)
    num_of_cycles.times do |n|
      GetPrimes.new.perform_async(n, 10)
    end
  end
end

pids = (1..5).to_a.map do
  fork do
    TestRunner.blocking(2_000)
    TestRunner.non_blocking(500)
    TestRunner.sort_array(1_000, 100)

    exit
  end
end

pids.each { |pid| Process.wait(pid) }
{'fraction_non_alphanumeric': 0.10599250936329588, 'fraction_numerical': 0.018352059925093634, 'mean_word_length': 3.336038961038961, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3341748', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1025, 'n_words': 198}