Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Use chunky_png/oily_png :fast_rgb option when saving
Browse files Browse the repository at this point in the history
According to the chunky_png wiki:

> ChunkyPNG tries to detect the optimal encoding parameters when saving
> an image. The detection costs some time, and it may choose a slow
> encoding method. To override the detection mechanism, and always save
> as RGB or RGBA image, use the @:fast_rgba@ or @:fast_rgb@ modifier
> when calling save

https://github.com/wvanbergen/chunky_png/wiki#encoding-options

Since we know that we are always only dealing with RGB images here and
speed is more important to us than space for this use-case, we can get a
nice little win here.

This brought the runtime on the Brigade diffux test suite down from
~170s to ~132s.
  • Loading branch information
lencioni committed Oct 19, 2015
1 parent cf7fd00 commit 07dce0f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/diffux_ci_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ def init_driver
# image to disk. This will allow it to be reviewed by someone.
diff_path = DiffuxCIUtils.path_to(
description, viewport['name'], 'diff.png')
comparison[:diff_image].save(diff_path)
comparison[:diff_image].save(diff_path, :fast_rgb)

candidate_path = DiffuxCIUtils.path_to(
description, viewport['name'], 'candidate.png')
screenshot.save(candidate_path)
screenshot.save(candidate_path, :fast_rgb)

puts "#{comparison[:diff_in_percent].round(1)}% (#{candidate_path})"
else
Expand All @@ -163,7 +163,7 @@ def init_driver
unless File.directory?(dirname = File.dirname(baseline_path))
FileUtils.mkdir_p(dirname)
end
screenshot.save(baseline_path)
screenshot.save(baseline_path, :fast_rgb)
puts "First snapshot created (#{baseline_path})"
end
end
Expand Down

1 comment on commit 07dce0f

@trotzig
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Please sign in to comment.