Spaces:
Paused
Paused
Delete app.py
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105import hashlibimport multiprocessing as mpimport osimport time
DURATION = int(os.getenv("DURATION", "60"))THREADS = int(os.getenv("THREADS", str(os.cpu_count() or 1)))
def worker(algorithm, seconds, queue): data = b"CPU-MINING-BENCHMARK" nonce = 0 count = 0
end = time.perf_counter() + seconds
if algorithm == "sha256": while time.perf_counter() < end: hashlib.sha256( data + nonce.to_bytes(8, "little") ).digest() nonce += 1 count += 1
elif algorithm == "sha512": while time.perf_counter() < end: hashlib.sha512( data + nonce.to_bytes(8, "little") ).digest() nonce += 1 count += 1
elif algorithm == "blake2b": while time.perf_counter() < end: hashlib.blake2b( data + nonce.to_bytes(8, "little") ).digest() nonce += 1 count += 1
queue.put(count)
def benchmark(algorithm): queue = mp.Queue() processes = []
start = time.perf_counter()
for _ in range(THREADS): p = mp.Process( target=worker, args=(algorithm, DURATION, queue) ) p.start() processes.append(p)
total = 0
for _ in processes: total += queue.get()
for p in processes: p.join()
elapsed = time.perf_counter() - start hps = total / elapsed
return hps
def main(): print("=" * 60) print(" CPU HASHRATE BENCHMARK") print("=" * 60) print(f"Threads : {THREADS}") print(f"Duration: {DURATION}s") print()
algorithms = [ "sha256", "sha512", "blake2b", ]
for algorithm in algorithms: hps = benchmark(algorithm)
print( f"{algorithm.upper():10} " f"{hps:,.0f} H/s " f"({hps / 1000:,.2f} KH/s)" )
print() print("NOTA:") print("H/s solo es comparable con el MISMO algoritmo.") print("Un SHA-256 H/s no equivale a RandomX, KawPow,") print("RandomHash, GhostRider, etc.") print("=" * 60)
if __name__ == "__main__": mp.freeze_support() main()app.pyDeleted-105