Re: Timing Curry programs

From: David Powers <david.powers_at_flinders.edu.au>
Date: Fri, 20 Oct 2017 08:13:49 +0000

Here is the test.curry I use to test myriad sorting routines (first import =
includes mysort) on both pakcs and kics2.
Note the $## for loop and the length print to force repetition/trick evalua=
tion - for the lazy evaluation trap Michael refers to:

import qsortsr
import System
import Random

test = do
        time 10
        time 100
        time 1000
        time 10000
        time 100000
        time 1000000

time n =
    let xs = take n (nextIntRange n 10000000)
        rep = 1000000 `div` n
    in do
        prin rep
        putStr " x "
        startc <- getCPUTime
        ys <- return $## for rep xs xs
        prin $ length ys -- lazy evaluation not done till forced
        endc <- getCPUTime
        putStr ": CPUTime "
        print $ endc-startc

tests = do
        times 10
        times 100
        times 1000
        times 10000
        times 100000
        times 1000000

times n =
    let xs = map show $ take n (nextIntRange n 10000000)
        rep = 1000000 `div` n
    in do
        prin rep
        putStr " x "
        startc <- getCPUTime
        ys <- return $## for rep xs xs
        prin $ length ys -- lazy evaluation not done till forced
        endc <- getCPUTime
        putStr ": CPUTime "
        print $ endc-startc



prin t = putStr (show t)

for n xs ys | n>0 = for (n-1) xs $## mysort xs
            | n==0 = ys

--
Prof. David M W Powers, Ph.D. Email: David.Powers_at_flinders.edu.au<=
mailto:David.Powers_at_flinders.edu.au>

Websites/Startups/Brands:
               http://flinders.edu.au/people/David.Powers
                             http://david.wardpowers.info<http://david.ward=
powers.info/>
                              http://www.youramigo.com.au<http://www.youram=
igo.com.au/>
                              http://www.annacares.com.au<http://www.annaca=
res.com.au/>
                              http://www.clevertar.com.au<http://www.clever=
tar.com.au/>

Professor of Computer Science & Cognitive Science, TON2.10
College of Science and Engineering (Phone: 08-=
8201 3663)
Flinders University, Tonsley, South Australia 5042 (Fax: +61-8-8201 3=
626)
GPO Box 2100 Adelaide SA 5001 (Mobile/Viber: 0414-824=
-307)
AUSTRALIA (Int'l Mob=
ile: +372 571 64540)

CRICOS Registered Provider: Flinders University | CRICOS Provider No: =
00114A








On 20 Oct 2017, at 6:32 pm, Michael Hanus <mh_at_informatik.uni-kiel.de<mailto=
:mh_at_informatik.uni-kiel.de>> wrote:

On 10/20/2017 12:15 AM, James Koppel wrote:
(I do prefer an answer for KiCS2 over PAKCS, because I have the
understanding that KiCS2 is faster.)

You have to be careful. You are right that KiCS2 is generally faster,
but this depends on the kind of applications. It is much faster for
purely deterministic computations, but for non-deterministic computations
it might not be the case. Since KiCS2 offer much more flexible
evaluation strategies, this comes with some cost. There are cases
where non-determinism is duplicated (due to the combination of laziness
and non-determinism) so that you might get an exponential increase
in some computations. See

http://drops.dagstuhl.de/opus/volltexte/2012/3616/

for a discussion (and partial solution).

Best regards,

Michael

On Thu, Oct 19, 2017 at 6:15 PM, James Koppel <jkoppel_at_mit.edu
<mailto:jkoppel_at_mit.edu>> wrote:

   How do time Curry programs? I'm looking through the KiCS2
   documentation, and I can't find any way to get the current system
   time (ifI want to time it internally), nor accept a command-line
   argument (if I want to use the time command).

   I want to do this because, I have a new approach to implementing
   direct-style nondeterminism in imperative languages, and I'd like to
   compare to the "built-in" nondeterminism of Curry.

   Sincerely,
   James Koppel
   MIT CSAIL

_______________________________________________
curry mailing list
curry_at_lists.rwth-aachen.de
https://mailman.rwth-aachen.de/mailman/listinfo/curry




_______________________________________________
curry mailing list
curry_at_lists.rwth-aachen.de
https://mailman.rwth-aachen.de/mailman/listinfo/curry
Received on Fr Okt 20 2017 - 11:32:32 CEST

This archive was generated by hypermail 2.3.0 : Do Jun 20 2024 - 07:15:13 CEST