home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d8xx / d811 / bsh.lha / bsh / time < prev    next >
Text File  |  1993-02-14  |  1KB  |  31 lines

  1. if #argv==1
  2.     eval time()
  3.     return
  4. endif
  5. local t_FlLvl t_be4 t_after t_elapsed cmd
  6. set cmd "$*"
  7. onintr goto foo
  8. set t_FlLvl `failat`
  9. failat 2147483647    # Some programs return pointers as exit code.
  10. t_be4=rtime()
  11. $cmd
  12. label foo
  13. t_after=rtime(),t_elapsed=float(t_after-t_be4)/50.
  14. if t_elapsed < 0.0    # did we cross midnight ?
  15.     t_elapsed += float (60*60*24)
  16. endif
  17. failat $t_FlLvl[2]
  18. echo >&2 time for $argv[1-*] = $t_elapsed seconds
  19. # time - use to determine the amount of time used by a program.  The
  20. # resolution is .02 seconds.  Time only determines the real time consumed;
  21. # this will generally be more than the cpu time used by a program.
  22. # The use of $* is not exactly elegant, as variable replacement is performed
  23. # after alias replacement thus precluding any alias substitution.  Also,
  24. # the $* must be a simple command (no pipes...), or a script containing
  25. # more complex commands.
  26. #
  27. # Time is presented as is; no warrantee is either expressed or implied
  28. # as to it's suitability to any purpose whatsoever.  You assume all the
  29. # risk for all damage, even if caused by a defect in the software,
  30. # no matter how awful.
  31.