Re: lispworks - speed and silly benchmarks...
Both clozure and sbcl compile everything loaded automatically, while
lw doesn't.
Maybe the op just forgot to compile the test function?
2011/10/8, Raymond Wiker <rwiker@gmail.com>:
>
> No changes with the paid version (Lispworks 6 profession 32-bit on MacOSX,
> in my case).
>
> However, I see that the elements in the array are integers below 100, which
> is very small compared with the number of elements. If the Lispworks #'sort
> function is based on quicksort, it is very likely that this is the reason
> that the sort operation is slow (because the "pivot" element is very likely
> to be poorly chosen at every recursive step - this would make quicksort
> O(n^2) rather than O(n logn).)
>
> I just tested with setting the range of the random numbers to the same as
> the number of elements, and I get *much* better performance - down from
> about 140 seconds (for the 1M-element) down to 1.14 seconds.
>
> Sooo, it appears that if you want to sort a large number of small values you
> either need a different sort algorithm, diffeerent data structures
> altogether, or choose a different implementation.
>
> Answering the question you didn't ask: Lispworks performance for real-life
> work is fine; I would expect better perfomance than something written in
> Java for the simple reason that Lisp lets you concentrate on the problem
> rather than the programming language/environment.
>
> On Oct 8, 2011, at 15:59 , Petter Egesund wrote:
>
>>
>> Hi
>>
>> I think Lispworks look great and I have downloaded the evaluation version.
>>
>> I am about to start a project where raw speed is important, and I have
>> done some very SMALL tests. Following a mail
>> (http://www.lispforum.com/viewtopic.php?f=2&t=228) about sorting a large
>> array in lisp I tried out this on my computer:
>>
>> (defun test ()
>> (declare (optimize (speed 3) (debug 0) (safety 0) (compilation-speed 0)))
>> (let ((a (make-array 10000000 :element-type 'fixnum)))
>> (declare (type (simple-array fixnum (*)) a))
>> (loop for i of-type fixnum from 0 below 10000000
>> do (setf (aref a i) (random 100)))
>> (setf a (sort a #'>))
>> nil))
>>
>> This takes about 9 seconds on my computer using clozure.
>>
>> Doing the same thing with in sbcl takes about 2.5 when i inline the
>> sort-function as well.
>>
>> Doing it all in java 1.7 takes about 0.6 seconds:
>>
>> int[] arr = new int[10000000];
>> Random generator = new Random();
>> for (int i=0; i<10000000; i++) {
>> arr[i] = generator.nextInt(100);
>> }
>> Arrays.sort(arr);
>> System.out.println("Arrays sorted in: " +
>> (System.currentTimeMillis() - start));
>>
>> Then to Lispworks, where the evaluation-vesion has to little heap-size to
>> compile and run the program.
>>
>> I change the size of the array from 10 000 000 to 1 000 000, and tries
>> again.
>>
>> Timing the function now in Lispworks takes over 4 MINUTES.
>>
>> This can probably be explained if the eval-version runs in some kind of
>> interpreted mode and does not compile (which is a petty, since an
>> eval-version is actually for evaluating the product)?!
>>
>> Or is Lispworks only so slow that I migh be better of doing the sorting by
>> hand myself? :-)
>>
>> Could someone with a paid version enlighten me on this one?
>>
>> Cheers,
>>
>> Petter Egesund
>>
>
>
--
Inviato dal mio dispositivo mobile