On 3/16/07, skaller <[EMAIL PROTECTED]> wrote:
> The idea is that you can write:
>
>         fun f(x:float): float => ... cost x *2.0;
>         fun g(x:float): float => ... cost x * x;
>
> so now, g is chosen for small x, whilst f is chosen for big x.

I think this sounds like a good idea, but who chooses the constants?
e.g. Say you implement f and give it cost x * 2.0 because it does two
multiplications for every x, and I implement it (without knowledge of
yours) and give it cost x * 3.0 because it does three additions for
every x.  On a PowerPC this is all good, but on a 386 multiplications
take much longer than additions and the cost measurement would be
incorrect.  One idea would be for the user to specify a cost function
of the form x * _ (where _ represents some constant), and (as you
suggested) let Felix profile the functions to fill in the constants.
The user would of course have to supply example data, e.g.

fun quicksort[n] (a: int^n): int^n => ... cost _ * x * lg x;

run_profile(quicksort, (3,5,2,1,4));

so Felix wouldn't pick inappropriate test data (as would be disastrous
in the case of algorithms like quicksort).

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to