|
From: Richard Howell-P. <ric...@gm...> - 2008-08-18 10:43:28
|
ok, I will look into that. Before I read your reply I wrote this code which
just does timings in Flint, then I was going to do some magma timings and do
the graph in Excel. I guess proper timings are important officially for the
project but if this way is quicker then I'd do it instead so I can get
something on my poster. Is this a reasonable way to time the factorisation
function? It seems to work for me but I'm not sure I trust the std C time
library very much.
here goes:
#include <time.h>
#include <sys/times.h>
#include <unistd.h>
/**
* Main timing function for zmod_poly_factorise
*/
#define MIN_LENGTH 250
#define MAX_LENGTH 270 //Maximum length of polynomial to be timed
#define NUMBER 3 //Number of random poly's we test to get average
time
void timing()
{
//Variables
clock_t start, end;
double total_time;
double timings[MAX_LENGTH - MIN_LENGTH]; //store the average time of
poly length [i]
zmod_poly_t input;
zmod_poly_factor_t factors;
printf("Computing Timings \n");
for(unsigned long k = MIN_LENGTH; k < MAX_LENGTH; ++k)
{
total_time = 0;
for(unsigned long i = 0; i < NUMBER; ++i)
{
//Set up a polynomial
zmod_poly_init(input, PRIME);
randpoly(input, k, PRIME);
zmod_poly_make_monic(input, input);
//set up factors
zmod_poly_factor_init(factors);
//Begin
printf(".");
start = clock();
//do stuff
zmod_poly_factorise(factors, input);
//End
end = clock();
printf("/");
fflush(stdout);
//Calc timing
total_time = ((double) (end - start)) / CLOCKS_PER_SEC;
//clear memory
zmod_poly_clear(input);
zmod_poly_factor_clear(factors);
}
total_time = ((double) total_time ) / NUMBER;
timings[k - MIN_LENGTH] = total_time;
}
//output the data
printf("\n\t \t Average Timings: \n");
printf("Length \t Average Time \n");
for(unsigned long k=0; k < MAX_LENGTH - MIN_LENGTH; ++k)
printf("%lu \t %f \n", k + MIN_LENGTH, timings[k]);
}
--
Richard
|