Sha256: dd20b25f7f59e90b173d9bd82cf51e846f53bae8d3e534c63d87bd503f5f0340

Contents?: true

Size: 502 Bytes

Versions: 1

Compression:

Stored size: 502 Bytes

Contents

# frozen_string_literal: true

require 'bundler/setup'
require 'polyphony'

def lengthy_op
  IO.orig_read(__FILE__)
end

X = 10000

def blocking
  t0 = Time.now
  data = lengthy_op
  X.times { lengthy_op }
  puts "read blocking #{data.bytesize} bytes (#{Time.now - t0}s)"
end

def threaded
  t0 = Time.now
  data = Polyphony::Thread.spawn { lengthy_op }.await
  X.times { Polyphony::Thread.spawn { lengthy_op } }
  puts "read threaded #{data.bytesize} bytes (#{Time.now - t0}s)"
end

blocking
threaded

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
polyphony-0.23 examples/core/thread.rb