Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!apple!oliveb!mipos3!omepd!merlyn From: merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge) Newsgroups: comp.emacs Subject: profiler (was Re: updated tools) Summary: my code attached Message-ID: <4453@omepd.UUCP> Date: 19 May 89 13:12:49 GMT References: <8905111747.AA17268@dsys.icst.nbs.gov> <40509@think.UUCP> Sender: news@omepd.UUCP Reply-To: merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge) Organization: Stonehenge; netaccess via BiiN, Hillsboro, Oregon, USA Lines: 42 In-reply-to: barmar@think.COM (Barry Margolin) In article <40509@think.UUCP>, barmar@think (Barry Margolin) writes: | In article <8905111747.AA17268@dsys.icst.nbs.gov> rbj@dsys.icst.nbs.GOV (Root Boy Jim) writes: [rbj's version deleted] | Here's a version that works around midnight: [barmar's version deleted] OK, I'll throw my response into the ring: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; snip snip (defun seconds-past-midnight () "Return seconds past midnight." (let ((time (current-time-string))) (+ (* 3600 (string-to-int (substring time 11 13))) (* 60 (string-to-int (substring time 14 16))) (string-to-int (substring time 17 19))))) (defun profile (func count) "Evaluate FUNC COUNT times, and return the number of wall-clock seconds." (let ((start-time (seconds-past-midnight)) (i count)) (while (>= (setq i (1- i)) 0) (eval func)) (% (- (seconds-past-midnight) start-time -86400) 86400))) (defun profile-it (func count) "Evaluate FUNC COUNT times, displaying the result." (interactive "xProfile Expression: \np") (message "profiling...") (message "%d iterations took %d seconds" count (profile func count))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; snip snip This version of "seconds-past-midnight" is faster than rbj's equivalent function (according to the profiler) . Apparently, the more parens you have in a function, the longer it takes to run it, no matter *what* you do . Just another Elisp hacker (last day, I think...) -- ***** PLEASE IGNORE THE ADDRESS IN THE HEADER ***** /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095===\ { ...!uunet!agora.hf.intel.com!merlyn } \=Cute quote: "Welcome to Oregon... home of the California Raisins!"=/