mirror of
https://github.com/pjreddie/darknet.git
synced 2023-08-10 21:13:14 +03:00
timing code
This commit is contained in:
parent
cb1f33c6ae
commit
aea3bceeb1
11
src/server.c
11
src/server.c
@ -6,6 +6,7 @@
|
|||||||
#include <netinet/in.h> /* needed for sockaddr_in */
|
#include <netinet/in.h> /* needed for sockaddr_in */
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include "mini_blas.h"
|
#include "mini_blas.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
@ -83,7 +84,7 @@ void handle_connection(void *pointer)
|
|||||||
{
|
{
|
||||||
connection_info info = *(connection_info *) pointer;
|
connection_info info = *(connection_info *) pointer;
|
||||||
free(pointer);
|
free(pointer);
|
||||||
printf("New Connection\n");
|
//printf("New Connection\n");
|
||||||
int fd = info.fd;
|
int fd = info.fd;
|
||||||
network net = info.net;
|
network net = info.net;
|
||||||
int i;
|
int i;
|
||||||
@ -118,7 +119,7 @@ void handle_connection(void *pointer)
|
|||||||
write_all(fd, (char *)layer.weights, layer.outputs*layer.inputs*sizeof(float));
|
write_all(fd, (char *)layer.weights, layer.outputs*layer.inputs*sizeof(float));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("Received updates\n");
|
//printf("Received updates\n");
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,17 +130,23 @@ void server_update(network net)
|
|||||||
listen(fd, 10);
|
listen(fd, 10);
|
||||||
struct sockaddr_in client; /* remote address */
|
struct sockaddr_in client; /* remote address */
|
||||||
socklen_t client_size = sizeof(client); /* length of addresses */
|
socklen_t client_size = sizeof(client); /* length of addresses */
|
||||||
|
time_t t=0;
|
||||||
while(1){
|
while(1){
|
||||||
connection_info *info = calloc(1, sizeof(connection_info));
|
connection_info *info = calloc(1, sizeof(connection_info));
|
||||||
info->net = net;
|
info->net = net;
|
||||||
info->counter = &counter;
|
info->counter = &counter;
|
||||||
pthread_t worker;
|
pthread_t worker;
|
||||||
int connection = accept(fd, (struct sockaddr *) &client, &client_size);
|
int connection = accept(fd, (struct sockaddr *) &client, &client_size);
|
||||||
|
if(!t) t=time(0);
|
||||||
info->fd = connection;
|
info->fd = connection;
|
||||||
pthread_create(&worker, NULL, (void *) &handle_connection, info);
|
pthread_create(&worker, NULL, (void *) &handle_connection, info);
|
||||||
++counter;
|
++counter;
|
||||||
|
printf("%d\n", counter);
|
||||||
|
if(counter == 1024) break;
|
||||||
if(counter%1000==0) save_network(net, "cfg/nist.part");
|
if(counter%1000==0) save_network(net, "cfg/nist.part");
|
||||||
}
|
}
|
||||||
|
printf("1024 epochs: %d seconds\n", time(0)-t);
|
||||||
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void client_update(network net, char *address)
|
void client_update(network net, char *address)
|
||||||
|
Loading…
Reference in New Issue
Block a user