File: cdir_read_from_stream_time.rb

package info (click to toggle)
ruby-zip 3.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 11,120 kB
  • sloc: ruby: 9,958; makefile: 23
file content (21 lines) | stat: -rw-r--r-- 563 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

require 'bundler/setup'
require 'zip'
require 'benchmark'
require 'benchmark/memory'

DATA_DIR = File.expand_path('../test/data', __dir__)

zip_file1 = File.open(File.join(DATA_DIR, 'globTest.zip'), 'rb')
zip_file2 = File.open(File.join(DATA_DIR, '100000-files.zip'), 'rb')
cdir1 = Zip::CentralDirectory.new
cdir2 = Zip::CentralDirectory.new

Benchmark.bmbm do |x|
  x.report('8 entries') { cdir1.read_from_stream(zip_file1) }
  x.report('100,000 entries') { cdir2.read_from_stream(zip_file2) }
end

zip_file1.close
zip_file2.close