Sha256: 32128a22caad7a43b41474b1d21608270a67748c2fff7c258effc1234bb8d9ca

Contents?: true

Size: 785 Bytes

Versions: 90

Compression:

Stored size: 785 Bytes

Contents

# frozen_string_literal: true

require 'bundler/setup'
require 'polyphony'
require 'polyphony/adapters/fs'

def raw_read_file(x)
  t0 = Time.now
  x.times { IO.orig_read(__FILE__) }
  puts "raw_read_file: #{Time.now - t0}"
end

def threaded_read_file(x, y)
  t0 = Time.now
  threads = []
  y.times do
    threads << Thread.new { x.times { IO.orig_read(__FILE__) } }
  end
  threads.each(&:join)
  puts "threaded_read_file: #{Time.now - t0}"
end

def thread_pool_read_file(x, y)
  t0 = Time.now
  y.times do
    spin { x.times { IO.read(__FILE__) } }
  end
  Fiber.current.await_all_children
  puts "thread_pool_read_file: #{Time.now - t0}"
end

Y = ARGV[0] ? ARGV[0].to_i : 10
X = ARGV[1] ? ARGV[1].to_i : 100

raw_read_file(X * Y)
threaded_read_file(X, Y)
thread_pool_read_file(X, Y)

Version data entries

90 entries across 90 versions & 1 rubygems

Version Path
polyphony-1.6 examples/performance/fs_read.rb
polyphony-1.5 examples/performance/fs_read.rb
polyphony-1.4 examples/performance/fs_read.rb
polyphony-1.3 examples/performance/fs_read.rb
polyphony-1.2.1 examples/performance/fs_read.rb
polyphony-1.2 examples/performance/fs_read.rb
polyphony-1.1.1 examples/performance/fs_read.rb
polyphony-1.1 examples/performance/fs_read.rb
polyphony-1.0.2 examples/performance/fs_read.rb
polyphony-1.0.1 examples/performance/fs_read.rb
polyphony-1.0 examples/performance/fs_read.rb
polyphony-0.99.6 examples/performance/fs_read.rb
polyphony-0.99.5 examples/performance/fs_read.rb
polyphony-0.99.4 examples/performance/fs_read.rb
polyphony-0.99.3 examples/performance/fs_read.rb
polyphony-0.99.2 examples/performance/fs_read.rb
polyphony-0.99.1 examples/performance/fs_read.rb
polyphony-0.99 examples/performance/fs_read.rb
polyphony-0.98 examples/performance/fs_read.rb
polyphony-0.97 examples/performance/fs_read.rb