<commit_before>#!/usr/bin/env ruby

$VERBOSE = true
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'proco'
require 'benchmark'
require 'parallelize'
require 'thread'
require 'logger'

logger = Logger.new($stdout)
times = 1_000_000

Benchmark.bm(40) do |x|
# x.report('threads') do
#   times.times.each_slice(64) do |slice|
#     ts = slice.map { Thread.new { } }
#     ts.each(&:join)
#   end
# end

  x.report('simple loop') do
    times.times do |i|
      Proco::Future.new
    end
  end

  x.report('Default Proco') do
    proco = Proco.new
    proco.start do |item|
      nil
    end

    times.times do |i|
      print '.' if i % 1000 == 0
      proco.submit! i
    end
    proco.exit
  end

  x.report('SizedQueue push and pop') do<commit_msg>celluloid<commit_after>#!/usr/bin/env ruby

$VERBOSE = true
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'proco'
require 'benchmark'
require 'parallelize'
require 'thread'
require 'logger'

logger = Logger.new($stdout)
times = 1_000_000

if celluloid = false
  require 'celluloid'
  class Cell
    include Celluloid

    def push
      Proco::Future.new
    end
  end
end

Benchmark.bm(40) do |x|
  x.report('celluloid') do
    c = Cell.new
    f = nil
    times.times do |i|
      print '.' if i % 1000 == 0
      f = c.future.push
    end
    f.value
  end if celluloid

  x.report('simple loop') do
    times.times do |i|
      Proco::Future.new
    end
  end

  x.report('Default Proco') do
    proco = Proco.new
    proco.start do |item|
      nil
    end

    times.times do |i|
      print '.' if i % 1000 == 0
      proco.submit! i
    end
    proco.exit
  end

  x.report('SizedQueue push and pop') do
{'fraction_non_alphanumeric': 0.13051146384479717, 'fraction_numerical': 0.0205761316872428, 'mean_word_length': 2.5311203319502074, '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': '2323078', 'n_tokens_mistral': 669, 'n_tokens_neox': 627, 'n_words': 168}