fork download
  1. puts "Type something here.\nTimer will be started as you start typing.\nPress Return key to stop the timer."
  2.  
  3. system("stty raw -echo")
  4. kostyl = STDIN.getc
  5. system("stty -raw echo")
  6.  
  7. start_time = Time.new
  8. print kostyl
  9. str = gets
  10. finish_time = Time.new
  11. result = str.length / (finish_time - start_time)
  12. puts "Your typing speed is #{'%.04f' %result} symbols per second"
Success #stdin #stdout #stderr 0.01s 7456KB
stdin
123
stdout
Type something here.
Timer will be started as you start typing.
Press Return key to stop the timer.
1Your typing speed is 84001.8480 symbols per second
stderr
stty: standard input: Inappropriate ioctl for device
stty: standard input: Inappropriate ioctl for device