Skip to content

Commit

Permalink
Merge pull request #412 from envato/save_image_threads_config
Browse files Browse the repository at this point in the history
Add config option to set threads for saving images
  • Loading branch information
bigmartyn authored Aug 13, 2018
2 parents 0c8d1a4 + a628269 commit 0fcd526
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/wraith/save_images.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def run_command(command)
end

def parallel_task(jobs)
Parallel.each(jobs, :in_threads => 8) do |_label, _path, width, url, filename, selector, global_before_capture, path_before_capture|
Parallel.each(jobs, :in_threads => wraith.save_image_threads) do |_label, _path, width, url, filename, selector, global_before_capture, path_before_capture|
begin
if meta.engine == "chrome"
capture_image_selenium(width, url, filename, selector, global_before_capture, path_before_capture)
Expand Down
4 changes: 4 additions & 0 deletions lib/wraith/wraith.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,8 @@ def verbose
# @TODO - also add a `--verbose` CLI flag which overrides whatever you have set in the config
@config["verbose"] || false
end

def save_image_threads
(@config["save_image_threads"] || 8).to_i
end
end
4 changes: 4 additions & 0 deletions spec/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
it "include compare label" do
expect(wraith.paths).to eq("home" => "/", "uk_index" => "/uk")
end

it "include save image threads" do
expect(wraith.save_image_threads).to eq(7)
end
end

describe "different ways of initialising browser engine" do
Expand Down
3 changes: 3 additions & 0 deletions spec/configs/test_config--casper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ paths:

#Amount of fuzz ImageMagick will use
fuzz: '20%'

# Number of threads used when saving images
save_image_threads: 7
4 changes: 4 additions & 0 deletions spec/configs/test_config--phantom.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ paths:

#Amount of fuzz ImageMagick will use
fuzz: '20%'


# Number of threads used when saving images
save_image_threads: 7
4 changes: 4 additions & 0 deletions templates/configs/capture.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,7 @@ gallery:
# diffs_only - only paths with a difference are shown, sorted by difference size (largest first)
# Note: different screen widths are always grouped together.
mode: diffs_first

# (optional) Set the number of threads to use when saving images. Raising this value can improve performance, but very high
# values can lead to server connection issues. Set to around 1.5 the available CPU cores for best performance. Default: 8
save_image_threads: 8
4 changes: 4 additions & 0 deletions templates/configs/history.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,7 @@ highlight_color: red

# (optional) Parameters to pass to Phantom/Casper command line. Default: '--ignore-ssl-errors=true --ssl-protocol=tlsv1'
phantomjs_options: ''

# (optional) Set the number of threads to use when saving images. Raising this value can improve performance, but very high
# values can lead to server connection issues. Set to around 1.5 the available CPU cores for best performance. Default: 8
save_image_threads: 8
4 changes: 4 additions & 0 deletions templates/configs/spider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,7 @@ directory: 'shots'
# diffs_first - all paths (with or without a difference) are shown, sorted by difference size (largest first)
# diffs_only - only paths with a difference are shown, sorted by difference size (largest first)
mode: diffs_first

# (optional) Set the number of threads to use when saving images. Raising this value can improve performance, but very high
# values can lead to server connection issues. Set to around 1.5 the available CPU cores for best performance. Default: 8
save_image_threads: 8

0 comments on commit 0fcd526

Please sign in to comment.