Добавил таймер
This commit is contained in:
parent
3efd67c703
commit
fbaf769b30
2 changed files with 19 additions and 5 deletions
|
@ -1,8 +1,10 @@
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "polygon.h"
|
#include "polygon.h"
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
points ps;
|
points ps;
|
||||||
|
int timer;
|
||||||
double shift;
|
double shift;
|
||||||
polygon plgn, new_polygon;
|
polygon plgn, new_polygon;
|
||||||
FILE * file = getFile();
|
FILE * file = getFile();
|
||||||
|
@ -28,10 +30,13 @@ int main(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
printPolygon(plgn, "\nOriginal polygon:\n");
|
printPolygon(plgn, "\nOriginal polygon:\n");
|
||||||
|
|
||||||
new_polygon = getPolygon(&plgn, shift);
|
|
||||||
|
|
||||||
|
timer = -clock();
|
||||||
|
new_polygon = getPolygon(&plgn, shift);
|
||||||
|
timer += clock();
|
||||||
|
|
||||||
printPolygon(new_polygon, "\n\nNew polygon:\n");
|
printPolygon(new_polygon, "\n\nNew polygon:\n");
|
||||||
|
printf("\nThe process took about %3.0lf seconds %3.0lf milliseconds", (double)timer / CLOCKS_PER_SEC, (double)(timer % CLOCKS_PER_SEC) / (CLOCKS_PER_SEC / 1000));
|
||||||
|
|
||||||
free(ps.arr);
|
free(ps.arr);
|
||||||
free(new_polygon.pts.arr);
|
free(new_polygon.pts.arr);
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "SCP.h"
|
#include "SCP.h"
|
||||||
#include "hope.h"
|
#include "hope.h"
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
points pts;
|
points pts;
|
||||||
point N[3];
|
point N[3];
|
||||||
circle crcl;
|
circle crcl;
|
||||||
int numLose;
|
int numLose, timer;
|
||||||
|
|
||||||
pts = getPoints();
|
pts = getPoints();
|
||||||
if (pts.array == NULL) return -1;
|
if (pts.array == NULL) return -1;
|
||||||
|
@ -14,18 +15,26 @@ int main(void) {
|
||||||
printPoints(pts);
|
printPoints(pts);
|
||||||
|
|
||||||
printf("\nFast algorithm:\n");
|
printf("\nFast algorithm:\n");
|
||||||
|
timer = -clock();
|
||||||
crcl = MEC(pts.array, pts.length, N, 0);
|
crcl = MEC(pts.array, pts.length, N, 0);
|
||||||
|
timer += clock();
|
||||||
printCircle(crcl);
|
printCircle(crcl);
|
||||||
|
|
||||||
if ((numLose = isCover(crcl, pts)) == pts.length) printf("\nThe circle covers all the points!\n");
|
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");
|
printf("\nReliable algorithm:\n");
|
||||||
|
timer = -clock();
|
||||||
crcl = hope(pts.array, pts.length);
|
crcl = hope(pts.array, pts.length);
|
||||||
|
timer += clock();
|
||||||
printCircle(crcl);
|
printCircle(crcl);
|
||||||
|
|
||||||
if (isCover(crcl, pts) == pts.length) printf("\nThe circle covers all the points!\n");
|
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);
|
free(pts.array);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue