title: Determine CPU frequency from command line
body: <p>I have a Bash script that detects CPU frequency from the command line and then calls the benchmark suit for a C/C++ library. Here's the essence of the script:</p>
  
  <pre><code># CPU frequency in GHz
  CPU_FREQ=2.0
  if [ "$IS_LINUX" -ne "0" ] &amp;&amp; [ -e "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq" ]; then
      CPU_FREQ=$(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq)
      CPU_FREQ=$(awk "BEGIN {print $CPU_FREQ/1024/1024}")
  elif [ "$IS_DARWIN" -ne "0" ]; then
      CPU_FREQ=$(sysctl -a 2&gt;/dev/null | $GREP 'hw.cpufrequency' | head -1 | awk '{print $3}')
      CPU_FREQ=$(awk "BEGIN {print $CPU_FREQ/1024/1024/1024}")
  elif [ "$IS_SOLARIS" -ne "0" ]; then
      CPU_FREQ=$(psrinfo -v 2&gt;/dev/null | $GREP 'MHz' | head -1 | nawk '{print $6}')
      CPU_FREQ=$(nawk "BEGIN {print $CPU_FREQ/1024}")
  fi
  </code></pre>
  
  <p>It just occurred to me the script is failing under Cygwin and Cygwin-64.</p>
  
  <p>How do I determine CPU frequency in the script under Cygwin and Cygwin-64?</p>