[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
if you are having trouble getting reasonable numbers for timing, use this time-it macro..
- To: Rao Kambhampati <rao@asu.edu>
- Subject: if you are having trouble getting reasonable numbers for timing, use this time-it macro..
- From: Subbarao Kambhampati <rao@asu.edu>
- Date: Sat, 21 Feb 2009 12:46:10 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=vLA9Z2vy40BnBe+Q4jU0rsy6ML86ZT2JiH5kI9z4LxY=; b=osHfgNNfh6ocuPXYWEs/kFGUoEwoMpVVVWz+vmnF5PW/xa8Ie+u3/v6hoDyVBoNd5M G5dGl1WivseZdRkKjPDUWH60A/FC8lB62+Al+luvrvxNha/xcHQnerNoEQgBvSd/7uIU T0e3lsrLzeF4hGaLTFjc+YVQgn+Abq+xMbDEQ=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=vrMgq+AmZK9Yv+HVO+wutE/n+uF5art2Eu2WxbW6nJ/C/Iz48YhVJE3jBpY8cRazod hCm0QkzplR5kjtFDbRL+uEKXSffdaHAnUH3jyE+xpYTqWeKtVwP+nqDuIHSieiLdKbBj 47jFREnVqnFLXvHKj1GKyF5y+KI0xa9Se9WvA=
- Sender: subbarao2z2@gmail.com
Cut the following code, paste it into your file and use it as
(time-it (your function that you want to time))
Lisp's macro facility is among the very best. Unlike defun, defmacro first constructs lisp code and then evaluates it. the backquote macro is a great way to
make templates...
(defmacro time-it (code)
`(let ((begtime (get-internal-run-time)))
,code
(float (/ (- (get-internal-run-time) begtime)
internal-time-units-per-second))))
rao