Добавил таймер
This commit is contained in:
parent
3efd67c703
commit
fbaf769b30
2 changed files with 19 additions and 5 deletions
|
@ -1,12 +1,13 @@
|
|||
#include "tools.h"
|
||||
#include "SCP.h"
|
||||
#include "hope.h"
|
||||
#include <time.h>
|
||||
|
||||
int main(void) {
|
||||
points pts;
|
||||
point N[3];
|
||||
circle crcl;
|
||||
int numLose;
|
||||
int numLose, timer;
|
||||
|
||||
pts = getPoints();
|
||||
if (pts.array == NULL) return -1;
|
||||
|
@ -14,18 +15,26 @@ int main(void) {
|
|||
printPoints(pts);
|
||||
|
||||
printf("\nFast algorithm:\n");
|
||||
timer = -clock();
|
||||
crcl = MEC(pts.array, pts.length, N, 0);
|
||||
timer += clock();
|
||||
printCircle(crcl);
|
||||
|
||||
if ((numLose = isCover(crcl, pts)) == pts.length) printf("\nThe circle covers all the points!\n");
|
||||
else printf("\nThe circle misses a maximum of %d points", pts.length - numLose);
|
||||
else printf("\nThe circle misses a maximum of %d points\n", pts.length - numLose);
|
||||
|
||||
printf("Quick search took about %3.0lf seconds %3.0lf milliseconds\n", (double)timer / CLOCKS_PER_SEC, (double)(timer % CLOCKS_PER_SEC) / (CLOCKS_PER_SEC / 1000));
|
||||
|
||||
printf("\nReliable algorithm:\n");
|
||||
timer = -clock();
|
||||
crcl = hope(pts.array, pts.length);
|
||||
timer += clock();
|
||||
printCircle(crcl);
|
||||
|
||||
if (isCover(crcl, pts) == pts.length) printf("\nThe circle covers all the points!\n");
|
||||
else printf("\nThe circle misses a maximum of %d points", pts.length - numLose);
|
||||
else printf("\nThe circle misses a maximum of %d points\n", pts.length - numLose);
|
||||
|
||||
printf("Slow search took about %3.0lf seconds %3.0lf milliseconds\n", (double)timer / CLOCKS_PER_SEC, (double)(timer % CLOCKS_PER_SEC) / (CLOCKS_PER_SEC / 1000));
|
||||
|
||||
free(pts.array);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue