1
0
Fork 0
mirror of git://git.psyc.eu/libpsyc synced 2024-08-15 03:19:02 +00:00

bench: fix for strlen & json-c tests

This commit is contained in:
tg(x) 2011-05-24 20:41:27 +02:00
parent 283b11c2cd
commit 05f6ba6be9
4 changed files with 33 additions and 18 deletions

View file

@ -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

View file

@ -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);

View file

@ -10,6 +10,7 @@
#include <getopt.h>
#include <sys/socket.h>
#define NOREAD
#include "test.c"
// cmd line args