diff --git a/.gitignore b/.gitignore index 2ede0bd..ccab349 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,6 @@ samples/_img samples/_output/*.png samples/_output/*.pdf samples/_output/foo -rubocop.txt \ No newline at end of file +rubocop.txt +benchmarks/_output/*.png +benchmarks/_output/*.pdf \ No newline at end of file diff --git a/Rakefile b/Rakefile index 108c9e1..ec87530 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,8 @@ +require 'squib' require 'bundler/gem_tasks' require 'rspec/core/rake_task' require 'yard' +require 'benchmark' task default: [:install, :spec] @@ -10,3 +12,15 @@ YARD::Rake::YardocTask.new(:doc) do |t| t.files = ['lib/**/*.rb', 'samples/**/*.rb'] # optional #t.options = ['--any', '--extra', '--opts'] # optional end + +task benchmark: [:install] do + Squib::logger.level = Logger::ERROR #silence warnings + Dir.chdir('benchmarks') do + Benchmark.bm(15) do |bm| + Dir['*.rb'].each do | script | + GC.start + bm.report(script) { load script } + end + end + end +end \ No newline at end of file diff --git a/benchmarks/shiny-purse.png b/benchmarks/shiny-purse.png new file mode 100644 index 0000000..477ef93 Binary files /dev/null and b/benchmarks/shiny-purse.png differ diff --git a/benchmarks/spanner.svg b/benchmarks/spanner.svg new file mode 100644 index 0000000..1f3a747 --- /dev/null +++ b/benchmarks/spanner.svg @@ -0,0 +1,91 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/benchmarks/tons_of_png.rb b/benchmarks/tons_of_png.rb new file mode 100644 index 0000000..6cfb9c4 --- /dev/null +++ b/benchmarks/tons_of_png.rb @@ -0,0 +1,6 @@ +require 'squib' + +Squib::Deck.new(cards: 200) do + png file: 'shiny-purse.png' + save_png prefix: 'tons_of_png_' +end \ No newline at end of file diff --git a/benchmarks/tons_of_svg.rb b/benchmarks/tons_of_svg.rb new file mode 100644 index 0000000..24a2bd2 --- /dev/null +++ b/benchmarks/tons_of_svg.rb @@ -0,0 +1,7 @@ +require 'squib' + +Squib::Deck.new(cards: 200) do + svg file: 'spanner.svg', + width: 400, height: 400 + save_png prefix: 'tons_of_svg_' +end \ No newline at end of file diff --git a/benchmarks/tons_of_text.rb b/benchmarks/tons_of_text.rb new file mode 100644 index 0000000..3d59510 --- /dev/null +++ b/benchmarks/tons_of_text.rb @@ -0,0 +1,8 @@ +require 'squib' + +Squib::Deck.new(cards: 200) do + text str: 'tweedle beetle battle ' * 250, + font: 'Sans bold 12', width: 825, + ellipsize: false + save_png prefix: 'tons_of_text_' +end \ No newline at end of file