File: png_export.rb

package info (click to toggle)
ruby-rqrcode 3.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 500 kB
  • sloc: ruby: 1,225; makefile: 4
file content (36 lines) | stat: -rw-r--r-- 1,114 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
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# frozen_string_literal: true

require_relative "benchmark_helper"

BenchmarkHelper.section "PNG Export Benchmarks"

# PRIMARY: End-to-end benchmark (generation + export)
BenchmarkHelper.run_ips_e2e("PNG Export") do |x, qr_data|
  x.report("png_small") { RQRCode::QRCode.new(qr_data[:small]).as_png }
  x.report("png_medium") { RQRCode::QRCode.new(qr_data[:medium]).as_png }
  x.report("png_large") { RQRCode::QRCode.new(qr_data[:large]).as_png }

  x.compare!
end

# DIAGNOSTIC: Rendering-only benchmark (isolates export performance)
BenchmarkHelper.run_ips("PNG Export") do |x, qrcodes|
  x.report("png_small") { qrcodes[:small].as_png }
  x.report("png_medium") { qrcodes[:medium].as_png }
  x.report("png_large") { qrcodes[:large].as_png }

  x.compare!
end

# Memory Profile - PNG Export
BenchmarkHelper.run_memory("PNG Export") do |qrcodes|
  25.times do
    qrcodes[:small].as_png
    qrcodes[:medium].as_png
    qrcodes[:large].as_png
  end
end

puts "\n✓ PNG benchmarks complete"
puts "  - End-to-end: Full user workflow (generation + export)"
puts "  - Rendering-only: Export performance in isolation"