|
From: Bill H. <goo...@go...> - 2008-08-18 11:26:46
|
Well, apart from the fact that you'll get a much nicer graph the other
way, and the fact that you are being a little unfair to yourself by
not subtracting the time it takes to generate the random polynomials,
this looks like it should work.
It's up to you how you'd like to present your data. You definitely
want to use more than 3 iterations, otherwise the timings will be very
inconsistent. Also, you want to use a number of different *sized*
primes and length polynomials. I suspect you'll find Magma is way
faster for very small primes.
I have in the past profiled by hand on occasion, as it is "quicker".
The time function is alright I find down to times of about 10ms. Of
course you can increase the amount of time by putting everything in a
loop and timing the whole loop. You will of course get microsecond
timing if you use the FLINT code. Magma uses millisecond timing, but
the example profile code is set up to do all the loops for you and
figure out the individual times.
Fortunately factorisation takes a long time on average, so it
shouldn't be that hard to time.
Bill.
2008/8/18 Richard Howell-Peak <ric...@gm...>:
> 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
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> flint-devel mailing list
> fli...@li...
> https://lists.sourceforge.net/lists/listinfo/flint-devel
>
>
|