Emacs Uptime
Since I tend to work in Emacs no matter what computer I’m using, I got curious after reading Steve Yegge’s latest post about XEmacs instability what exactly my uptimes are on all my Emacs sessions (I use GNU Emacs, but I was still curious). This is some elisp I threw together to answer that question.
(require 'cl)
(defun duration (time)
"Takes in a time-value and returns the number of seconds since
the epoch that value represents."
(+ (* 65536 (car time)) (cadr time)))
(defun uptime ()
"Prints the current uptime of Emacs as recorded on startup in
the value 'start-time'"
(interactive)
(let* ((total (duration (time-subtract (current-time) start-time)))
(days (floor (/ total 86400)))
(hours (progn (decf total (* days 86400)) (floor (/ total 3600))))
(mins (progn (decf total (* hours 3600)) (floor (/ total 60))))
(secs (progn (decf total (* mins 60)) (floor total))))
(message "%d days, %d hours, %d minutes, %d seconds" days hours mins secs)))
; Put this in your .emacs
(setq start-time (current-time))
You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Comments are closed.