<commit_before>require 'socket'
require 'time'

if ARGV.length != 1
  puts 'Usage:'
  puts '  ruby speed_test.rb <file containing test message>'
  exit 1
end

large_string = IO.read(ARGV.shift)
msg = "pub stdout #{large_string}\n"

retries = 0
iterations = 100_000
start_time = Time.now
iterations.times do |i|
  begin
    socket = UNIXSocket.new('/tmp/mini-pubsub.sock')
    socket.write msg
    socket.close
  rescue
    retries += 1
    retry
  end
end

puts "#{'%.2f' % (iterations / (Time.now - start_time))}/sec, with #{retries} retries"<commit_msg>Changes to speed test<commit_after>require 'socket'
require 'time'

if ARGV.length != 1
  puts 'Usage:'
  puts '  ruby speed_test.rb <file containing test message>'
  exit 1
end

msgs = IO.read(ARGV.shift)
num_msgs = msgs.lines.length

retries = 0
start_time = Time.now
msgs.each_line do |msg|
  begin
    socket = UNIXSocket.new('/tmp/mini-pubsub.sock')
    socket.write msg
    socket.close
  rescue
    retries += 1
    retry
  end
end

puts "#{'%.2f' % (num_msgs / (Time.now - start_time))}/sec, with #{retries} retries"
{'fraction_non_alphanumeric': 0.13067655236329936, 'fraction_numerical': 0.014828544949026877, 'mean_word_length': 3.4628099173553717, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6560166', 'n_tokens_mistral': 415, 'n_tokens_neox': 403, 'n_words': 106}