#!/usr/bin/env node /** * Generate consistent test inputs for jdenticon benchmarking * Creates deterministic hash strings for fair comparison between Go and JS implementations */ const fs = require('fs'); const crypto = require('crypto'); const NUM_INPUTS = 1000; const inputs = []; // Generate deterministic inputs by hashing incremental strings for (let i = 0; i < NUM_INPUTS; i++) { // Use a variety of input types to make the benchmark realistic let input; if (i % 4 === 0) { input = `user${i}@example.com`; } else if (i % 4 === 1) { input = `test-hash-${i}`; } else if (i % 4 === 2) { input = `benchmark-input-${i.toString(16)}`; } else { // Use a deterministic source for the "random" part const randomPart = crypto.createHash('sha1').update(`seed-${i}`).digest('hex').substring(0, 12); input = `random-string-${randomPart}`; } // Generate SHA1 hash (same as jdenticon uses) const hash = crypto.createHash('sha1').update(input).digest('hex'); inputs.push(hash); } // Write inputs to JSON file const outputPath = './inputs.json'; fs.writeFileSync(outputPath, JSON.stringify(inputs, null, 2)); console.log(`Generated ${NUM_INPUTS} test inputs and saved to ${outputPath}`); console.log(`Sample inputs:`); console.log(inputs.slice(0, 5));