What's Your Hash Rate? Find out your Mining Speed w/ compute_hash_with_proof_of_work

Hello,

  I've added a couple of new chapters to the "Programming Blockchains
Step-by-Step from Scratch (Zero)" [1] and starting with (crypto)
hashes...

  What's News? Mining, mining, mining! What's your hash rate? Let's
find out and use the "stand-alone" version of the by now "classic"
compute_hash_with_proof_of_work function:

    def compute_hash_with_proof_of_work( data, difficulty='00' )
      nonce = 0
      loop do
        hash = Digest::SHA256.hexdigest( "#{nonce}#{data}" )
        if hash.start_with?( difficulty )
          return [nonce,hash] ## bingo! proof of work if hash starts
w/ leading zeros (00)
        else
          nonce += 1 ## keep trying (and trying and trying)
        end
      end # loop
    end # method compute_hash_with_proof_of_work

  Let's try (run) benchmarks for the difficulty from 0 (4 bits) to
0000000 (28 bits)...

  On my "low-end" home computer the hash rate per second is...
about 100 000. What's yours?

   Cheers. Prost. Happy blockchaining and mining with ruby.

[1] https://github.com/openblockchains/programming-blockchains-step-by-step#mining-mining-mining