File: read_chunks.rb

package info (click to toggle)
ruby-async-io 1.34.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 424 kB
  • sloc: ruby: 3,103; makefile: 4
file content (18 lines) | stat: -rwxr-xr-x 377 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env ruby
# frozen_string_literal: true

require_relative 'memory'

require_relative "../../lib/async/io/stream"
require "stringio"

measure_memory("Stream setup") do
	@io = StringIO.new("a" * (50*1024*1024))
	@stream = Async::IO::Stream.new(@io)
end # 50.0 MB

measure_memory("Read all chunks") do
	while chunk = @stream.read_partial
		chunk.clear
	end
end # 0.5 MB