code: func (m *CPUMiner) speedMonitor() {
  	log.Tracef("CPU miner speed monitor started")
  
  	var hashesPerSec float64
  	var totalHashes uint64
  	ticker := time.NewTicker(time.Second * hpsUpdateSecs)
  	defer ticker.Stop()
  
  out:
  	for {
  		select {
  		// Periodic updates from the workers with how many hashes they
  		// have performed.
  		case numHashes := <-m.updateHashes:
  			totalHashes += numHashes
  
  		// Time to update the hashes per second.
  		case <-ticker.C:
  			curHashesPerSec := float64(totalHashes) / hpsUpdateSecs
  			if hashesPerSec == 0 {
  				hashesPerSec = curHashesPerSec
  			}
  			hashesPerSec = (hashesPerSec + curHashesPerSec) / 2
  			totalHashes = 0
  			if hashesPerSec != 0 {
  				log.Debugf("Hash speed: %6.0f kilohashes/s",
  					hashesPerSec/1000)
  			}
  
  		// Request for the number of hashes per second.
  		case m.queryHashesPerSec <- hashesPerSec:
  			// Nothing to do.
  
  		case <-m.speedMonitorQuit:
  			break out
  		}
  	}
  
  	m.wg.Done()
  	log.Tracef("CPU miner speed monitor done")
  }
docs: // speedMonitor handles tracking the number of hashes per second the mining
  // process is performing.  It must be run as a goroutine.