Sha256: f65002fd38b27067a13bdd3900bb90e7367a71d5d33097d0491abfb34eeb2528

Contents?: true

Size: 861 Bytes

Versions: 7

Compression:

Stored size: 861 Bytes

Contents

# -*- encoding: utf-8 -*-

# Benchmark speed of table operations

$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)

require 'tty'
require 'benchmark'
require 'benchmark/ips'

header        = [:name, :color]
rows          = (1..100).map { |n| ["row#{n}", "red"] }
table         = TTY::Table.new(header, rows)
table_ascii   = TTY::Table.new(header, rows, :renderer => :ascii)
table_unicode = TTY::Table.new(header, rows, :renderer => :unicode)
table_color   = TTY::Table.new(header, rows, :renderer => :ascii, :border => { :style => :red })

Benchmark.ips do |r|

  r.report("Ruby #to_s") do
    rows.to_s
  end

  r.report("TTY #to_s") do
    table.to_s
  end

  r.report("TTY ASCII #to_s") do
    table_ascii.to_s
  end

  r.report("TTY Unicode #to_s") do
    table_unicode.to_s
  end

  r.report("TTY Color #to_s") do
    table_color.to_s
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tty-0.1.2 benchmarks/table.rb
tty-0.1.1 benchmarks/table.rb
tty-0.1.0 benchmarks/table.rb
tty-0.0.11 benchmarks/table.rb
tty-0.0.10 benchmarks/table.rb
tty-0.0.9 benchmarks/table.rb
tty-0.0.8 benchmarks/table.rb