~refi64/alys

e827fc4c2728a2538e0fc8b050adac96ff601c67 — Ryan Gonzalez 1 year, 2 months ago 3687bca
Expand the demo to make testing / benchmarking easier
1 files changed, 26 insertions(+), 6 deletions(-)

M example/demo.cr
M example/demo.cr => example/demo.cr +26 -6
@@ 1,10 1,30 @@
require "../src/alys"

require "option_parser"
require "uuid"

require "../src/alys"

class X
  def initialize(@quiet : Bool)
  end

  def finalize
    puts 123
    puts 123 if !@quiet
  end
end

sleep_ms = 1000
iterations = 0
quiet = false

OptionParser.parse do |parser|
  parser.on "--sleep=MS", "Sleep duration" do |value|
    sleep_ms = value.to_i
  end
  parser.on "--iterations=ITERATIONS", "Iteration count" do |value|
    iterations = value.to_i
  end
  parser.on "--quiet", "Be quiet" do
    quiet = true
  end
end



@@ 13,13 33,13 @@ Alys.setup_from_env

objs = [] of UUID

loop do
  X.new
(0..(iterations > 0 ? iterations : nil)).each do |_|
  X.new quiet
  ptr = GC.malloc 10
  ptr = GC.realloc ptr, 20
  GC.free ptr
  Regex.new "abc"
  objs << UUID.random
  GC.collect
  sleep 1.seconds
  sleep sleep_ms.milliseconds unless sleep_ms <= 0
end