Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

CL benchmarking

Name: Anonymous 2014-10-12 6:59

Is there a free benchmarking library for Common Lisp? Something like Haskell's Criterion, perhaps?

Name: Anonymous 2014-10-12 11:43

So, it seems that the Haskell ecosystem is already richer than the Lisp ecosystem. LITHP is so stillborn.
http://www.serpentine.com/criterion/

Name: Anonymous 2014-10-12 13:50

You don't need to benchmark it since you already know it's slow as fuck.

GC is shit.

Name: Anonymous 2014-10-12 19:05

lol you noobs think you know better than those old bearded white male professors, yeah huh i wonder why they came up with gc and lisp and huh
lol you don't know how to program
lol haskell still isn't used in the real world (science, military) unlike c and lisp

Name: Anonymous 2014-10-12 19:41

Why do Lisp faggot and Haskell faggots always fight each other? They're both the result of academic circlejerking. I like both, what the fuck makes them some kind of mutually exclusive worlds?

Name: Anonymous 2014-10-14 13:50

>>5

Because Haskell cannot into macros and Haskellers feel their inferiority.

Name: Anonymous 2014-10-14 15:43

>>6
I would prefer TH to lisp macri any time of the week.

Name: Anonymous 2014-10-14 19:05

>>7
0/10

Name: Anonymous 2014-10-14 19:30

>>8
Reduce you are fractions, fecalface.

Name: Anonymous 2014-10-18 5:25

>>5
I don't want to bash LITHP, I want to have a sensible tool for microbenchmarking it.

Name: Anonymous 2014-10-18 13:17

Alright, perhaps some of you lispers already know some of the answers.

1) I've read that keyword args are slower than common args. Is this true? How much do they slow down function calls? What about optional args?

2) What's the approximate cost of CLOS method dispatch? For instance: if one adds up a million boxed pairs of flonums, how much slower is it going to be if addition is defined as a generic, compared to using primitive addition?

Name: Anonymous 2014-10-18 14:44

The easiest way is to get support from the implementation itself. But if that is not possible, a bunch of macros could be used to generate benchmark collection code. As the program runs, code should generate a list of function calls (or code positions) time stamped by when they were executed. Macros can do this by inserting calls that add data to a global object. Then once the data is collected, it can be organized in different ways.

>>11
1)
These both depend on the implementation. There is no theoretical reason that would cause a keyword function to perform slower than a regular one, but an implementation might create a dictionary and pass it to the function, which would be slower. I think that's how python does it?

2)
Depends on the implementation again. There is a look up to match the argument types to a method implementation. Performance depends on how that structure is implemented. This feature is more challenging than the method overriding in seeples and java since the dispatch can be done on all arguments rather than just the this instance. If the types of the arguments are known at compile time the CLOS dispatch can be optimized out and the called method inserted, in theory, but lisp is so dynamic I don't know if this can be done safely.

Name: Anonymous 2014-10-18 16:33

>>12
a bunch of macros could be used to
code should generate
Macros can do this

Ah, the sempiternal "could be done" curse of Lisp. Macros could do anything, in theory, but in practice using them is so hard that no one actually achieved anything practical with Lisp.

Name: Anonymous 2014-10-18 16:47

The type system of CLOS has been formally described as "lambda-&" calculus in a 2001 paper by Castagna, Ghelli and Longo.

Yes, CL has a type system. Lisp is statically typed. In order to understand CL, you need to know type theory.

Have you read your TAPL today?

Name: Anonymous 2014-10-18 16:50

Haskell-kun, why are your type system posts always completely unrelated to the actual topic?

Name: Anonymous 2014-10-18 16:54

>>15
Because type theory is an area of mathematics completely unrelated to haxing anii, checking dubz and computation in general.

Name: Anonymous 2014-10-18 18:55

>>13
Normally you wouldn't be able to trigger me into doing this, but I haven't written lisp in a while and this time it was fun.

(defpackage #:bench-mark
(:use #:cl)
(:export #:hello))

(in-package #:bench-mark)

(defun hello ()
(print "hello"))

(defvar bench-log nil)
(defvar kw-call "call")
(defvar kw-return "return")

(defun clear-bench-log ()
(setq bench-log nil))

(defun append-bench-log (ent)
(push ent bench-log))

(defun function-called (name time)
(append-bench-log (list kw-call name time)))

(defun function-returned (name time)
(append-bench-log (list kw-return name time)))

(defun profile-test1 (x)
(let (ret)
(function-called 'profile-test1 (get-internal-real-time))
(setq ret (loop for i from 1 to x sum i))
(function-returned 'profile-test1 (get-internal-real-time))
ret))

(defmacro profiled-body (name &rest body)
(let ((ret-sym (gensym)))
`(let (,ret-sym)
(function-called ,name (get-internal-real-time))
(setq ,ret-sym (progn ,@body))
(function-returned ,name (get-internal-real-time))
,ret-sym)))

(defun profile-test2 (x)
(profiled-body 'profile-test2
(loop for i from 1 to x sum i)))

(defmacro defun-prof (name args &rest body)
`(defun ,name ,args
(profiled-body ',name
,@body)))

(defmacro defmethod-prof (name args &rest body)
`(defmethod ,name ,args
(profiled-body ',name
,@body)))

(defmacro lambda-prof (name args &rest body)
`(lambda ,args
(profiled-body ',name
,@body)))

(defun-prof profile-test3 (x)
(loop for i from 1 to x sum i))

(defmethod-prof profile-test4 ((x integer))
(loop for i from 1 to x sum i))

(defun profile-test5 (x)
(funcall (lambda-prof profile-test5 (x)
(loop for i from 1 to x sum i))
x))

Name: Anonymous 2014-10-18 18:57

(:export #:hello))

(defun hello ()
(print "hello"))

please disregard this

Name: Anonymous 2014-10-19 5:22

>>17
Well thanks, I guess.

Name: Anonymous 2014-10-19 8:32

>>19
I don't like you are tone.

Name: Anonymous 2014-10-19 10:32

>>17 should use an unwind protect actually.

(defpackage #:bench-mark
(:use #:cl)
(:export #:bench-log #:kw-call #:kw-return #:clear-bench-log
#:append-bench-log #:function-called #:function-returned
#:profiled-body #:defun-prof #:defmethod-prof
#:lambda-prof))

(in-package #:bench-mark)

(defvar bench-log nil)
(defvar kw-call "call")
(defvar kw-return "return")

(defun clear-bench-log ()
(setq bench-log nil))

(defun append-bench-log (ent)
(push ent bench-log))

(defun function-called (name time)
(append-bench-log (list kw-call name time)))

(defun function-returned (name time)
(append-bench-log (list kw-return name time)))

(defun profile-test1 (x)
(let (ret)
(function-called 'profile-test1 (get-internal-real-time))
(setq ret (loop for i from 1 to x sum i))
(function-returned 'profile-test1 (get-internal-real-time))
ret))

(defmacro profiled-body (name &rest body)
`(unwind-protect
(progn
(function-called ',name (get-internal-real-time))
,@body)
(function-returned ',name (get-internal-real-time))))

(defun profile-test2 (x)
(profiled-body profile-test2
(loop for i from 1 to x sum i)))

(defmacro defun-prof (name args &rest body)
`(defun ,name ,args
(profiled-body ,name
,@body)))

(defmacro defmethod-prof (name args &rest body)
`(defmethod ,name ,args
(profiled-body ,name
,@body)))

(defmacro lambda-prof (name args &rest body)
`(lambda ,args
(profiled-body ',name
,@body)))

(defun-prof profile-test3 (x)
(loop for i from 1 to x sum i))

(defmethod-prof profile-test4 ((x integer))
(loop for i from 1 to x sum i))

(defun profile-test5 (x)
(funcall (lambda-prof profile-test5 (x)
(loop for i from 1 to x sum i))
x))

(defun profile-test6 (x)
(let (n)
(tagbody
(profiled-body profile-test6
(setq n (loop for i from 1 to x sum i))
(go out)
(print "never happens"))
out)
n))

Name: Anonymous 2014-10-19 12:10

>>20
You don't like the thanks or the guessing?

Name: Anonymous 2014-10-19 17:42

>>17
HIT THE BENCH AND SEND IT UP! YOU REPULSIVE SACK OF ATROPHY!

Name: Anonymous 2014-10-20 0:54

>>23
ahh! *runs away and hides behind corner.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List