auto-account-machine/browser-automation-ts/test-bin-distribution.mjs
2025-11-27 10:34:59 +08:00

48 lines
1.6 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 测试BIN分布
*/
import pkg from './src/tools/card/CardGeneratorTool.js';
const { CardGeneratorTool } = pkg;
async function test() {
console.log('生成1000张卡分析BIN分布...\n');
const cardGen = new CardGeneratorTool();
await cardGen.initialize({});
const cards = await cardGen.generateBatch(1000, 'unionpay');
// 统计BIN分布
const binCounts = {};
cards.forEach(card => {
const bin = card.number.slice(0, 13);
binCounts[bin] = (binCounts[bin] || 0) + 1;
});
// 排序
const sorted = Object.entries(binCounts)
.sort((a, b) => b[1] - a[1]);
console.log('=== BIN分布前10个 ===\n');
sorted.slice(0, 10).forEach(([bin, count], i) => {
const percent = (count / 1000 * 100).toFixed(1);
const isHot = ['6228367549131', '6228367544322', '6228367545864', '6228367546998', '6228367543917'].includes(bin);
const mark = isHot ? '🔥' : ' ';
console.log(`${i + 1}. ${mark} ${bin}: ${count}次 (${percent}%)`);
});
// 统计热门BIN的总占比
const hotBins = ['6228367549131', '6228367544322', '6228367545864', '6228367546998', '6228367543917'];
const hotCount = hotBins.reduce((sum, bin) => sum + (binCounts[bin] || 0), 0);
const hotPercent = (hotCount / 1000 * 100).toFixed(1);
console.log(`\n=== 热门BIN统计 ===`);
console.log(`热门BIN总占比: ${hotCount}/1000 (${hotPercent}%)`);
console.log(`期望占比: ~${(5 * 5 / (5 * 5 + 60 * 1) * 100).toFixed(1)}% (权重5 vs 权重1)`);
}
test().catch(err => {
console.error('错误:', err.message);
console.error(err.stack);
});