Created
July 12, 2021 00:30
-
-
Save markizano/7a22018efeac91b16fec302cf290af91 to your computer and use it in GitHub Desktop.
Calculate dollar/hash and hash/watt of various GPU from MongoDB.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function aggregateGpus(gpu) { | |
var result = '%name:\n'.replace('%name', gpu.name); | |
result += ' Price (USD): %price\n'.replace('%price', gpu.price); | |
result += ' HashRate (MH/s): %hr\n'.replace('%hr', gpu.hashrate); | |
result += ' Power (W): %power\n'.replace('%power', gpu.power); | |
result += ' $/MH: %dph\n'.replace('%dph', gpu.pricePerHash); | |
result += ' MH/W: %hpw\n\n'.replace('%hpw', gpu.hashPerWatt); | |
print(result); | |
} | |
db.gpus.aggregate([ | |
{ | |
$project: { | |
_id: 0, | |
name: "$name", | |
hashrate: "$hashrate.count", | |
power: "$power.count", | |
price: "$price.count", | |
} | |
}, { | |
$project: { | |
name: 1, | |
hashrate: 1, | |
power: 1, | |
price: 1, | |
pricePerHash: { $divide: [ "$price", "$hashrate"] }, | |
hashPerWatt: { $divide: [ "$hashrate", "$power" ] } | |
} | |
}, { | |
$sort: { hashPerWatt: 1 } | |
} | |
]).forEach(aggregateGpus); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment