Sha256: 865da04452a97d7b0fa6dc4271c26bc3e499ca944fffece738357f90391ae71e

Contents?: true

Size: 1.46 KB

Versions: 740

Compression:

Stored size: 1.46 KB

Contents

require File.join(File.expand_path(File.dirname(__FILE__)), '../../../..', 'test_helper.rb')

require 'rbbt-util'
require 'rbbt/util/log'
require 'rbbt/util/concurrency/processes/socket'

class TestConcurrency < Test::Unit::TestCase
  def test_socket_push_pop
    obj1 = [1,[2,3,4]] #* 1000
    obj2 = ["1",["2","3","4"]] #* 1000
    obj3 = "some string"
    obj4 = TSV.setup({1 => 1})

    socket = RbbtProcessQueue::RbbtProcessSocket.new  Marshal
    10.times do
      socket.push(obj1)
      socket.push(obj2)
      socket.push(obj3)
      socket.push(obj4)

      assert_equal obj1, socket.pop
      assert_equal obj2, socket.pop 
      assert_equal obj3, socket.pop 
      assert_equal obj4, socket.pop 

    end

    socket.swrite.close
    assert_raise ClosedStream do 
      socket.pop
    end

    socket.clean
  end
end

if false and __FILE__ == $0
  socket = RbbtProcessQueue::RbbtProcessSocket.new 

  obj = "Some string" * 1000
  Misc.benchmark(1000) do
    socket.push(obj)
    socket.pop
  end

  obj = ["Some string"] * 1000
  Misc.benchmark(1000) do
    socket.push(obj)
    socket.pop
  end
  socket.clean


  socket = RbbtProcessQueue::RbbtProcessSocket.new Marshal

  obj = "Some string" * 1000
  Misc.benchmark(1000) do
    socket.push(obj)
    socket.pop
  end
  socket.clean

  socket = RbbtProcessQueue::RbbtProcessSocket.new TSV::StringArraySerializer
  obj = ["Some string"] * 1000
  Misc.benchmark(1000) do
    socket.push(obj)
    socket.pop
  end
  socket.clean
end

Version data entries

740 entries across 740 versions & 1 rubygems

Version Path
rbbt-util-5.43.0 test/rbbt/util/concurrency/processes/test_socket.rb
rbbt-util-5.42.0 test/rbbt/util/concurrency/processes/test_socket.rb
rbbt-util-5.41.1 test/rbbt/util/concurrency/processes/test_socket.rb
rbbt-util-5.41.0 test/rbbt/util/concurrency/processes/test_socket.rb
rbbt-util-5.40.5 test/rbbt/util/concurrency/processes/test_socket.rb
rbbt-util-5.40.4 test/rbbt/util/concurrency/processes/test_socket.rb
rbbt-util-5.40.3 test/rbbt/util/concurrency/processes/test_socket.rb
rbbt-util-5.40.0 test/rbbt/util/concurrency/processes/test_socket.rb
rbbt-util-5.39.0 test/rbbt/util/concurrency/processes/test_socket.rb
rbbt-util-5.38.1 test/rbbt/util/concurrency/processes/test_socket.rb
rbbt-util-5.38.0 test/rbbt/util/concurrency/processes/test_socket.rb
rbbt-util-5.37.16 test/rbbt/util/concurrency/processes/test_socket.rb
rbbt-util-5.37.15 test/rbbt/util/concurrency/processes/test_socket.rb
rbbt-util-5.37.14 test/rbbt/util/concurrency/processes/test_socket.rb
rbbt-util-5.37.13 test/rbbt/util/concurrency/processes/test_socket.rb
rbbt-util-5.37.12 test/rbbt/util/concurrency/processes/test_socket.rb
rbbt-util-5.37.11 test/rbbt/util/concurrency/processes/test_socket.rb
rbbt-util-5.37.10 test/rbbt/util/concurrency/processes/test_socket.rb
rbbt-util-5.37.9 test/rbbt/util/concurrency/processes/test_socket.rb
rbbt-util-5.37.8 test/rbbt/util/concurrency/processes/test_socket.rb