Performance

delta trinity deltatrinity at hotmail.com
Thu Feb 19 18:07:02 CET 2004


One way, efficient, could be to declare them static.  Initialize them only 
once.

Ex:

...
static mpf_t A,B,C;
static int Initialized=0;

if (!Initialized)
{
   mpf_init_set(A,...
   mpf_init_set(B,...
   mpf_init_set(C,...
   Initialized=1;
}
... (The rest of the function)

Then, the first time, and only the first time the function is called, the 
variables get initialized.

Of course, when the progam terminate, thw structs don't get cleared, but 
usually, the OS clear any memory used locally by the program when program 
terminate.

Eric

>From: Herr Witten <lingwitt at bellsouth.net>
>To: GMP Mailing list <gmp-discuss at swox.com>
>Subject: Performance
>Date: Mon, 16 Feb 2004 10:55:49 -0500
>
>In my program, the number of allocations of mpfs per loop is the same. 
>Would it be wise to allocate all of them, store pointers in a list of sorts 
>and then just grab one that isn't being used, or is there a better way? 
>Thanks.
>
>_______________________________________________
>gmp-discuss mailing list
>gmp-discuss at swox.com
>https://gmplib.org/mailman/listinfo/gmp-discuss

_________________________________________________________________
Take off on a romantic weekend or a family adventure to these great U.S. 
locations. http://special.msn.com/local/hotdestinations.armx



More information about the gmp-discuss mailing list