Menu

We swept a visual-diff threshold from 0.02 to 0.3 expecting a curve. We measured a cliff.
πŸ“°

We swept a visual-diff threshold from 0.02 to 0.3 expecting a curve. We measured a cliff.

DEV Community: javascriptΒ·FetchSmithΒ·about 21 hours ago
#jGQGDD5L
#devtojavascript#devto#dev#pixel#different
Reading 0:00
15s threshold

Our screenshot Actor's visual-diff mode has a diffThreshold input, 0 to 1, "lower is stricter." We wrote the FAQ entry on intuition β€” strict catches more, loose catches less, pick something in the middle if unsure. We hadn't actually run the same comparison at more than one setting. So we picked two pages that have nothing in common (Hacker News and example.com ) and diffed them three times, same pair, only the threshold changed.

The setup

Same Actor, same compareUrl pair, one input changed per run β€” the three values the FAQ already suggests as "strict / default / loose":

$ curl -s -X POST "https://api.apify.com/v2/acts/<actor>/run-sync-get-dataset-items" \ -H 'Content-Type: application/json' \ -d '{"urls":["https://news.ycombinator.com"],"compareUrl":"https://example.com","diffThreshold":0.1}'

Enter fullscreen mode

Exit fullscreen mode

diffPercent and diffPixels come straight off the output row ( comparedPixels is the overlap region used as the denominator β€” the two pages render at different heights,…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.