|
@@ -1,5 +1,6 @@
|
|
#include <stdio.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdlib.h>
|
|
|
|
+#include <time.h>
|
|
|
|
|
|
typedef struct {
|
|
typedef struct {
|
|
int fitness;
|
|
int fitness;
|
|
@@ -8,6 +9,12 @@ typedef struct {
|
|
|
|
|
|
Square* squares;
|
|
Square* squares;
|
|
|
|
|
|
|
|
+long getNanos() {
|
|
|
|
+ struct timespec t;
|
|
|
|
+ clock_gettime(CLOCK_MONOTONIC, &t);
|
|
|
|
+ return t.tv_nsec + t.tv_sec * 1000000000L;
|
|
|
|
+}
|
|
|
|
+
|
|
int size = 0;
|
|
int size = 0;
|
|
int population = 0;
|
|
int population = 0;
|
|
int (*fitness)(int*) = NULL;
|
|
int (*fitness)(int*) = NULL;
|
|
@@ -213,6 +220,8 @@ int main(int argAmount, char** args) {
|
|
default: puts("unknown type"); return 0;
|
|
default: puts("unknown type"); return 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ long time = -getNanos();
|
|
|
|
+
|
|
for(int h = 0; h < 5; h++) {
|
|
for(int h = 0; h < 5; h++) {
|
|
init();
|
|
init();
|
|
int half = population / 2;
|
|
int half = population / 2;
|
|
@@ -232,5 +241,8 @@ int main(int argAmount, char** args) {
|
|
print(squares);
|
|
print(squares);
|
|
clear();
|
|
clear();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ time += getNanos();
|
|
|
|
+ printf("Millis: %lf\n", time / 1000000.0);
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|