Sha256: 94bc15aa9eef92c2f7cf36208d4d5ff97d3a392e31635cd64e9e5e39203f53e7

Contents?: true

Size: 853 Bytes

Versions: 6

Compression:

Stored size: 853 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'bundler/setup'
require 'srx'
require 'optparse'
require 'memory_profiler'

options = {}
OptionParser.new do |opts|
  opts.banner = "Usage: #{$PROGRAM_NAME} [options]"

  opts.on('-sFILE', '--srx FILE', 'SRX file (optional)')
  opts.on('-fFORMAT', '--format FORMAT', 'Format of input text (default: text)')
end.parse!(into: options)

data = if options[:srx]
         Srx::Data.from_file(path: options[:srx])
       else
         Srx::Data.default
       end
format = options[:format]&.to_sym || :text
engine = Srx::Engine.new(data, format: format)

license_text = File.open(File.expand_path('../LICENSE.txt', __dir__), &:read).strip.then { |t| Srx::Util.unwrap(t) }

n = 100

report = MemoryProfiler.report do
  n.times { engine.segment(license_text, language: 'en') }
end

report.pretty_print

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
srx-0.6.0 bin/profile
srx-0.5.0 bin/profile
srx-0.4.0 bin/profile
srx-0.3.0 bin/profile
srx-0.2.0 bin/profile
srx-0.1.0 bin/profile