Skip to content

Instantly share code, notes, and snippets.

@BobbyWibowo
Created November 17, 2019 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BobbyWibowo/f999544f065b06becddd7945ad907afa to your computer and use it in GitHub Desktop.
Save BobbyWibowo/f999544f065b06becddd7945ad907afa to your computer and use it in GitHub Desktop.
// TODO
const args = process.argv.slice(2)
const size = parseFloat(args[0])
const seedtime = parseFloat(args[1])
let seeders = parseInt(args[2])
;(async () => {
if (!args.length)
throw new Error('Usage: bph.js <size=GB> <seedtime=H> [seeders]')
if (isNaN(size) || size <= 0)
throw new Error('Invalid torrent size.')
if (isNaN(seedtime) || seedtime <= 0)
throw new Error('Invalid seeding time.')
if (isNaN(seeders) || seeders <= 0)
seeders = 1
const seedtimeday = 1 / 24 * seedtime // hours to days
const a = 0.07 * Math.log(1 + seedtimeday)
const b = seeders ^ 0.35 // Math.max(seeders, 1) ^ 0.35
const c = 0.0433 + (a / b)
const bph = size * c
return bph
})()
.catch(error => {
console.error(error.toString())
process.exit(1)
})
.then(result => {
console.log(`Torrent size: ${size} GiB`)
console.log(`Seeding time: ${seedtime} hour(s)`)
console.log(`Seeders : ${seeders}`)
console.log(`BP/hour : ${result.toFixed(2)}`)
console.log(`BP/day : ${(result * 24).toFixed(2)}`)
console.log(`BP/week : ${(result * 24 * 7).toFixed(2)}`)
console.log(`BP/month : ${(result * 24 * 30).toFixed(2)}`)
console.log(`BP/year : ${(result * 24 * 365.25).toFixed(2)}`)
process.exit(0)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment