From 05f6ba6be968edb3c530289bb26ba5e276fc306b Mon Sep 17 00:00:00 2001 From: "tg(x)" <*@tg-x.net> Date: Tue, 24 May 2011 20:41:27 +0200 Subject: [PATCH] bench: fix for strlen & json-c tests --- bench/benchmark.org | 22 +++++++++++----------- test/Makefile | 10 +++++----- test/test.c | 18 ++++++++++++++++-- test/testStrlen.c | 1 + 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/bench/benchmark.org b/bench/benchmark.org index c6e9bd2..b0c5b73 100644 --- a/bench/benchmark.org +++ b/bench/benchmark.org @@ -155,17 +155,17 @@ Parsing large amounts of binary data. For JSON & XML base64 encoding was used. Note that the results below include only the parsing time, base64 decoding was not performed. -| input: | PSYC | | JSON | | | XML | | -| parser: | strlen | libpsyc | json-c | json-glib | libxml sax | libxml | rapidxml | -|---------+--------+---------+--------+------------+------------+-----------+----------| -| 7K | 92 | 77 | 14459 | 98000 | 11445 | 19299 | 8701 | -| 70K | 53 | 77 | 14509 | 1003900 | 96209 | 167738 | 74296 | -| 700K | 42 | 77 | 14551 | 10616000 | 842025 | 1909428 | 729419 | -| 7M | 258 | 78 | 14555 | 120810000 | 12466610 | 16751363 | 7581169 | -| 70M | 304 | 80 | 14534 | 1241000000 | 169622110 | 296017820 | 75308906 | -|---------+--------+---------+--------+------------+------------+-----------+----------| -| / | < | > | < | > | < | | > | -| | | | | | | | | +| input: | PSYC | | JSON | | | XML | | +| parser: | strlen | libpsyc | json-c | json-glib | libxml sax | libxml | rapidxml | +|---------+----------+---------+-----------+------------+------------+-----------+----------| +| 7K | 978 | 77 | 18609 | 98000 | 11445 | 19299 | 8701 | +| 70K | 9613 | 77 | 187540 | 1003900 | 96209 | 167738 | 74296 | +| 700K | 95888 | 77 | 1883500 | 10616000 | 842025 | 1909428 | 729419 | +| 7M | 1347300 | 78 | 26359000 | 120810000 | 12466610 | 16751363 | 7581169 | +| 70M | 14414000 | 80 | 357010000 | 1241000000 | 169622110 | 296017820 | 75308906 | +|---------+----------+---------+-----------+------------+------------+-----------+----------| +| / | < | > | < | > | < | | > | +| | | | | | | | | These tests were performed on a 2.53 GHz Intel(R) Core(TM)2 Duo P9500 CPU. diff --git a/test/Makefile b/test/Makefile index f7f49ea..29b0d05 100644 --- a/test/Makefile +++ b/test/Makefile @@ -87,16 +87,16 @@ bench-dir: @mkdir -p ../bench/results bench-psyc: bench-dir testStrlen testPsycSpeed - for f in ../bench/packets/*.psyc ../bench/packets/binary/*.psyc; do bf=`basename $$f`; echo strlen: $$bf; ./testStrlen -sc 1000000 -f $$f | ${TEE} -a ../bench/results/$$bf.strlen; done - for f in ../bench/packets/*.psyc ../bench/packets/binary/*.psyc; do bf=`basename $$f`; echo libpsyc: $$f; ./testPsycSpeed -sc 1000000 -f $$f | ${TEE} -a ../bench/results/$$bf; done + for f in ../bench/packets/*.psyc `ls ../bench/packets/binary/*.psyc | sort -r`; do bf=`basename $$f`; echo strlen: $$bf; ./testStrlen -sc 1000000 -f $$f | ${TEE} -a ../bench/results/$$bf.strlen; done + for f in ../bench/packets/*.psyc `ls ../bench/packets/binary/*.psyc | sort -r`; do bf=`basename $$f`; echo libpsyc: $$f; ./testPsycSpeed -sc 1000000 -f $$f | ${TEE} -a ../bench/results/$$bf; done bench-json: bench-dir testStrlen testJson testJsonGlib - for f in ../bench/packets/*.json ../bench/packets/binary/*.json; do bf=`basename $$f`; echo strlen: $$bf; ./testStrlen -sc 1000000 -f $$f | ${TEE} -a ../bench/results/$$bf.strlen; done - for f in ../bench/packets/*.json ../bench/packets/binary/*.json; do bf=`basename $$f`; echo json-c: $$bf; ./testJson -snc 1000000 -f $$f | ${TEE} -a ../bench/results/$$bf; done +# for f in ../bench/packets/*.json `ls ../bench/packets/binary/*.json | sort -r`; do bf=`basename $$f`; echo strlen: $$bf; ./testStrlen -sc 1000000 -f $$f | ${TEE} -a ../bench/results/$$bf.strlen; done + for f in ../bench/packets/*.json `ls ../bench/packets/binary/*.json | sort -r`; do bf=`basename $$f`; echo json-c: $$bf; ./testJson -snc 1000000 -f $$f | ${TEE} -a ../bench/results/$$bf; done for f in ../bench/packets/*.json; do bf=`basename $$f`; echo json-glib: $$bf; ./testJsonGlib -snc 1000000 -f $$f | ${TEE} -a ../bench/results/$$bf-glib; done bench-xml: bench-dir testStrlen - for f in ../bench/packets/*.xml ../bench/packets/binary/*.xml; do bf=`basename $$f`; echo strlen: $$bf; ./testStrlen -sc 1000000 -f $$f | ${TEE} -a ../bench/results/$$bf.strlen; done +# for f in ../bench/packets/*.xml `ls ../bench/packets/binary/*.xml | sort -r`; do bf=`basename $$f`; echo strlen: $$bf; ./testStrlen -sc 1000000 -f $$f | ${TEE} -a ../bench/results/$$bf.strlen; done bench-genpkts: @${MAKE} genpkt header=../bench/packets/binary/psyc-header content=../bench/packets/binary/psyc-content bs=7000 of=../bench/packets/binary/7K.psyc diff --git a/test/test.c b/test/test.c index 6c30028..1265a5c 100644 --- a/test/test.c +++ b/test/test.c @@ -52,7 +52,7 @@ void *get_in_addr (struct sockaddr *sa) { void test_file(const char* filename, size_t count, size_t recv_buf_size) { char *buf, *recvbuf; // cont buf + recv buf: [ ccrrrr] - size_t i, nbytes, size = 0; + size_t i, nbytes, size; struct timeval start, end; struct stat st; @@ -64,7 +64,8 @@ void test_file(const char* filename, size_t count, size_t recv_buf_size) { fstat(fd, &st); - buf = malloc(CONT_BUF_SIZE + st.st_size); + size = CONT_BUF_SIZE + st.st_size; + buf = malloc(size); if (!buf) { perror("malloc"); exit(1); @@ -77,13 +78,26 @@ void test_file(const char* filename, size_t count, size_t recv_buf_size) { if (stats) gettimeofday(&start, NULL); +#ifdef NOREAD + memset(buf, 1, size); +#else + size = 0; +#endif + for (i = 0; i < count; i++) +#ifndef NOREAD while ((nbytes = read(fd, (void*)recvbuf, recv_buf_size))) +#endif test_input(0, recvbuf, nbytes); } else { +#ifdef NOREAD + memset(buf, 1, size); +#else + size = 0; while ((nbytes = read(fd, (void*)recvbuf + size, RECV_BUF_SIZE))) size += nbytes; +#endif if (stats) gettimeofday(&start, NULL); diff --git a/test/testStrlen.c b/test/testStrlen.c index 9bd6866..40a50a5 100644 --- a/test/testStrlen.c +++ b/test/testStrlen.c @@ -10,6 +10,7 @@ #include #include +#define NOREAD #include "test.c" // cmd line args