Module: Perfgate::Fingerprints::WorkloadDefinition

Defined in:
lib/perfgate/fingerprints/workload_definition.rb

Overview

Computes a per-workload definition hash from the properties that, if changed, would make a historical run incomparable to a new one (spec section 15.4): the workload's id, its sample/warmup counts, and the set of metrics it records. Hashing the workload's source code (to detect behavioral changes even when these properties are unchanged) is explicitly deferred -- the spec notes this requires normalizing formatting/whitespace-only diffs, which is a larger follow-up.

Class Method Summary collapse

Class Method Details

.hash_for(workload) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/perfgate/fingerprints/workload_definition.rb', line 19

def hash_for(workload)
  payload = {
    "id" => workload.id,
    "samples" => workload.samples,
    "warmup" => workload.warmup,
    "metrics" => Array(workload.metrics).map(&:to_s).sort
  }
  "sha256:#{Digest::SHA256.hexdigest(JSON.generate(payload))}"
end