diff --git a/examples/bench_1/main.c b/examples/bench_1/main.c new file mode 100644 index 0000000000000000000000000000000000000000..8aff611dcaeb6fefc288fdd6714e67aaed426547 --- /dev/null +++ b/examples/bench_1/main.c @@ -0,0 +1,20 @@ +#include +#include "../../reowolf.h" +#include "../utility.c" +int main(int argc, char** argv) { + Arc_ProtocolDescription * pd = protocol_description_parse("", 0); + char logpath[] = "./bench_1.txt"; + Connector * c = connector_new_logging(pd, logpath, sizeof(logpath)-1); + connector_connect(c, -1); + printf("Error str `%s`\n", reowolf_error_peek(NULL)); + + clock_t begin = clock(); + int i; + for (i=0; i<1000000; i++) { + connector_sync(c, -1); + } + clock_t end = clock(); + double time_spent = (double)(end - begin) / CLOCKS_PER_SEC; + printf("Time taken: %f\n", time_spent); + return 0; +} \ No newline at end of file diff --git a/examples/bench_1/main_16.c b/examples/bench_1/main_16.c deleted file mode 100644 index 4762e8c0d402ae7b39f9556874b2347435553b0d..0000000000000000000000000000000000000000 --- a/examples/bench_1/main_16.c +++ /dev/null @@ -1,36 +0,0 @@ -#include "../../reowolf.h" -#include "../utility.c" -int main(int argc, char** argv) { - Arc_ProtocolDescription * pd = protocol_description_parse("", 0); - char logpath[] = "./1_16.txt"; - Connector * c = connector_new_logging(pd, logpath, sizeof(logpath)-1); - rw_err_peek(c); - - PortId putter, getter; - FfiSocketAddr local_addr = {{0, 0, 0, 0}, 8000}; - FfiSocketAddr peer_addr = {{8, 8, 8, 1}, 8001}; - rw_err_peek(c); - connector_add_udp_mediator_component(c, &putter, &getter, local_addr, peer_addr); - connector_connect(c, -1); - rw_err_peek(c); - - // Prepare a message to send - size_t msg_len = 16; - char * msg_ptr = malloc(msg_len); - memset(msg_ptr, 42, msg_len); - - int i; - for(i=0; i<10; i++) { - connector_put_bytes(c, putter, msg_ptr, msg_len); - rw_err_peek(c); - connector_sync(c, -1); - rw_err_peek(c); - } - - printf("Exiting\n"); - protocol_description_destroy(pd); - connector_destroy(c); - free(msg_ptr); - sleep(1.0); - return 0; -} \ No newline at end of file diff --git a/examples/bench_1/main_16k.c b/examples/bench_1/main_16k.c deleted file mode 100644 index 2992d1f8cbba7b692176e23827cfa91b9d6f15a9..0000000000000000000000000000000000000000 --- a/examples/bench_1/main_16k.c +++ /dev/null @@ -1,36 +0,0 @@ -#include "../../reowolf.h" -#include "../utility.c" -int main(int argc, char** argv) { - Arc_ProtocolDescription * pd = protocol_description_parse("", 0); - char logpath[] = "./1_16k.txt"; - Connector * c = connector_new_logging(pd, logpath, sizeof(logpath)-1); - rw_err_peek(c); - - PortId putter, getter; - FfiSocketAddr local_addr = {{0, 0, 0, 0}, 8000}; - FfiSocketAddr peer_addr = {{8, 8, 8, 1}, 8001}; - rw_err_peek(c); - connector_add_udp_mediator_component(c, &putter, &getter, local_addr, peer_addr); - connector_connect(c, -1); - rw_err_peek(c); - - // Prepare a message to send - size_t msg_len = 16000; - char * msg_ptr = malloc(msg_len); - memset(msg_ptr, 42, msg_len); - - int i; - for(i=0; i<10; i++) { - connector_put_bytes(c, putter, msg_ptr, msg_len); - rw_err_peek(c); - connector_sync(c, -1); - rw_err_peek(c); - } - - printf("Exiting\n"); - protocol_description_destroy(pd); - connector_destroy(c); - free(msg_ptr); - sleep(1.0); - return 0; -} \ No newline at end of file diff --git a/examples/bench_2/main.c b/examples/bench_2/main.c new file mode 100644 index 0000000000000000000000000000000000000000..6973eaa6ab092e48cf3877da2623c47d80912587 --- /dev/null +++ b/examples/bench_2/main.c @@ -0,0 +1,25 @@ +#include +#include "../../reowolf.h" +#include "../utility.c" +int main(int argc, char** argv) { + int i; + Arc_ProtocolDescription * pd = protocol_description_parse("", 0); + char logpath[] = "./bench_2.txt"; + Connector * c = connector_new_logging(pd, logpath, sizeof(logpath)-1); + int port_pairs = atoi(argv[1]); + printf("Port pairs: %d\n", port_pairs); + for (i=0; i +#include "../../reowolf.h" +#include "../utility.c" +int main(int argc, char** argv) { + int i, port_pairs; + port_pairs = atoi(argv[1]); + printf("Port pairs: %d\n", port_pairs); + + Arc_ProtocolDescription * pd = protocol_description_parse("", 0); + char logpath[] = "./bench_3.txt"; + Connector * c = connector_new_logging(pd, logpath, sizeof(logpath)-1); + for (i=0; i +#include "../../reowolf.h" +#include "../utility.c" +int main(int argc, char** argv) { + int i, proto_components; + proto_components = atoi(argv[1]); + printf("proto_components: %d\n", proto_components); + + const unsigned char pdl[] = + "primitive trivial_loop() { " + " while(true) synchronous{}" + "} " + ; + Arc_ProtocolDescription * pd = protocol_description_parse(pdl, sizeof(pdl)-1); + char logpath[] = "./bench_4.txt"; + Connector * c = connector_new_logging(pd, logpath, sizeof(logpath)-1); + for (i=0; i