prawnpdf/ttfunk

Performance Problem: TTFunk::Subset#encode 30x slower than v1.5.1

kokuyouwind opened this issue · 0 comments

Problem

In v1.6.2.1, TTFunk::Subset#encode takes about 30x longer than v1.5.1.

Reproduction Code

require 'ttfunk'
require 'benchmark'

# English Font
file = TTFunk::File.open("DejaVuSans.ttf")
# Japanese Font
# file = TTFunk::File.open("GenShinGothic-Normal.ttf")

subset = TTFunk::Subset.for(file, :unicode)
Benchmark.bmbm { |x| x.report('encode') { 10.times { subset.encode } } }

Results

ttfunk version font time[s]
v1.5.1 DejaVuSans.ttf 0.035328
v1.6.2.1 DejaVuSans.ttf 1.336027
v1.5.1 GenShinGothic-Normal.ttf 0.161720
v1.6.2.1 GenShinGothic-Normal.ttf 4.500678

Profile

TTFunk::Table::OS2.group_original_code_points_by_bit and TTFunk::Table::OS2.group_original_code_points_by_bit took a lot of time in stackprof profile.