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

bench: testPsycFast results

This commit is contained in:
Gabor Adam Toth 2011-05-16 20:13:10 +02:00
parent 3213934471
commit 13fdac0613
8 changed files with 133 additions and 24 deletions

1
.gitignore vendored
View file

@ -10,6 +10,7 @@ test/testMatch
test/testParser
test/testRender
test/testPsyc
test/testPsycFast
test/testText
test/isRoutingVar
test/getVarType

View file

@ -8,6 +8,8 @@ INIT = (setq load-path (cons \"/usr/share/emacs/site-lisp/org-mode\" load-path)
org-src-preserve-indentation t) \
(require 'org-install)
ORG = benchmark.org results.org
wiki2org:
perl -pe '\
s/^= (.*) =\s*$$/#+TITLE: $$1\n/; \
@ -17,18 +19,21 @@ wiki2org:
s/^}}}/#+END_SRC/ \
' benchmark.wiki >benchmark.org
tangle:
packets:
emacs -Q --batch --eval \
"(progn ${INIT} (find-file \"benchmark.org\") \
(org-babel-tangle) (kill-buffer))"
perl -pi -e 'print "\n" unless $$p; $$p=1' packets/user_profile.psyc
html:
emacs -Q --batch --eval \
"(progn ${INIT} (find-file \"benchmark.org\") \
(org-export-as-html-batch) (kill-buffer))"
for f in ${ORG}; do \
emacs -Q --batch --eval \
"(progn ${INIT} (find-file \"$$f\") \
(org-export-as-html-batch) (kill-buffer))"; \
done
pdf:
emacs -Q --batch --eval \
"(progn ${INIT} (find-file \"benchmark.org\") \
(org-export-as-pdf org-export-headline-levels) (kill-buffer))"
for f in ${ORG}; do \
emacs -Q --batch --eval \
"(progn ${INIT} (find-file \"$@.org\") \
(org-export-as-pdf org-export-headline-levels) (kill-buffer))"

View file

@ -5,20 +5,22 @@
Parsing time of 1 000 000 packets in milliseconds:
| | libpsyc | json-c | json-glib | libxml sax | libxml | rapidxml fast | rapidxml |
|-----------+---------+--------+-----------+------------+--------+---------------+----------|
| presence | 597 | 3247 | 10197 | 4997 | 7557 | 1643 | 1719 |
| chat msg | 714 | | | 5997 | 9777 | 1799 | 1893 |
| activity | 903 | 5768 | 16846 | 13357 | 28858 | 4001 | 4419 |
| user prof | 1806 | 5847 | 17468 | 7350 | 12377 | 2218 | 2477 |
| / | <> | < | > | < | > | < | > |
| | libpsyc | libpsyc fast | json-c | json-glib | libxml sax | libxml | rapidxml fast | rapidxml |
|-----------+---------+--------------+--------+-----------+------------+--------+---------------+----------|
| presence | 597 | 246 | 3247 | 10197 | 4997 | 7557 | 1643 | 1719 |
| chat msg | 714 | 320 | | | 5997 | 9777 | 1799 | 1893 |
| activity | 903 | 366 | 5768 | 16846 | 13357 | 28858 | 4001 | 4419 |
| user prof | 1806 | 608 | 5847 | 17468 | 7350 | 12377 | 2218 | 2477 |
|-----------+---------+--------------+--------+-----------+------------+--------+---------------+----------|
| / | < | > | < | > | < | > | < | > |
* Commands used
: ./testPsyc -snc 1000000 -f $file
: ./testPsycFast -sc 1000000 -f $file
: ./testJson -snc 1000000 -f $file
: ./testJsonGlib -snc 1000000 -f $file
: ./testStrlen -sc 1000000 -f $file
: ./rapidxml 1000000 $file
: fast_mode=1 ./rapidxml 1000000 $file
: ./libxml 1000000 $file

View file

@ -1,9 +1,10 @@
OPT = -O2
DEBUG = 2
CFLAGS = -I../include -I../src -Wall -std=c99 ${OPT}
CFLAGS_COMMON = -Wall -std=c99 ${OPT}
CFLAGS = -I../include -I../src ${CFLAGS_COMMON}
LDFLAGS = -L../lib
LOADLIBES = -lpsyc -lm
TARGETS = testPsyc testParser testMatch testRender testText isRoutingVar getVarType
TARGETS = testPsyc testPsycFast testParser testMatch testRender testText isRoutingVar getVarType
O = test.o
WRAPPER =
DIET = diet
@ -20,7 +21,8 @@ all: ${TARGETS}
it: all
testPsyc: LOADLIBES := ${LOADLIBES} ${LOADLIBES_NET}
testPsyc: test.o
testPsycFast: LOADLIBES := ${LOADLIBES} ${LOADLIBES_NET}
#testPsycFast: LOADLIBES := ${LOADLIBES_NET}
diet: WRAPPER = ${DIET}
diet: all

View file

@ -5,6 +5,10 @@
* "The C source code presented in this document is hereby granted to the public domain, and is completely free of any license restriction."
*/
#ifndef __USE_POSIX
# define __USE_POSIX
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -18,7 +22,6 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#define __USE_POSIX
#include <netdb.h>
#include "test.h"

View file

@ -1,10 +1,18 @@
#ifndef TEST_H
# define TEST_H
#ifndef RECV_BUF_SIZE
# define RECV_BUF_SIZE 8 * 1024
#endif
#ifndef CONT_BUF_SIZE
# define CONT_BUF_SIZE 8 * 1024
#endif
#ifndef SEND_BUF_SIZE
# define SEND_BUF_SIZE 8 * 1024
#endif
#ifndef NUM_PARSERS
# define NUM_PARSERS 100
#endif
void test_init(int i);
int test_input(int i, char *recvbuf, size_t nbytes);

View file

@ -12,7 +12,7 @@
#include <psyc/render.h>
#include <psyc/syntax.h>
#include "test.h"
#include "test.c"
// max size for routing & entity header
#define ROUTING_LINES 16
@ -31,8 +31,9 @@ psycModifier entity[NUM_PARSERS][ENTITY_LINES];
int contbytes, exit_code;
static inline void resetString (psycString *s, uint8_t freeptr);
t
static inline
void resetString (psycString *s, uint8_t freeptr);
// initialize parser & packet variables
void test_init (int i) {
// reset parser state & packet
@ -301,8 +302,7 @@ int test_input (int i, char *recvbuf, size_t nbytes) {
return ret;
}
static inline
void resetString (psycString *s, uint8_t freeptr)
inline void resetString (psycString *s, uint8_t freeptr)
{
if (freeptr && s->length)
free((void*)s->ptr);

88
test/testPsycFast.c Normal file
View file

@ -0,0 +1,88 @@
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
#include <unistd.h>
#include <getopt.h>
#include <sys/socket.h>
//#define PSYC_PARSE_INLINE
//#include "../src/parse.c"
#include <psyc/parse.h>
#include "test.c"
// max size for routing & entity header
#define ROUTING_LINES 16
#define ENTITY_LINES 32
// cmd line args
char *filename, *port = "4440";
uint8_t verbose, stats;
uint8_t routing_only;
size_t count = 1, recv_buf_size = RECV_BUF_SIZE;
psycParseState parser;
void test_init (int i) {
// reset parser state
if (routing_only)
psyc_initParseState2(&parser, PSYC_PARSE_ROUTING_ONLY);
else
psyc_initParseState(&parser);
}
int test_input (int i, char *recvbuf, size_t nbytes) {
char oper;
psycString name, value;
int ret;
parser.buffer = (psycString){nbytes, recvbuf};
parser.cursor = 0;
for (;;) {
ret = psyc_parse(&parser, &oper, &name, &value);
if (ret == PSYC_PARSE_COMPLETE || ret < 0)
return -1;
}
}
int main (int argc, char **argv) {
int c;
while ((c = getopt (argc, argv, "f:p:b:c:qrsvh")) != -1) {
switch (c) {
case 'f': filename = optarg; break;
case 'p': port = optarg; check_range(c, optarg, 1, 0); break;
case 'b': recv_buf_size = atoi(optarg); check_range(c, optarg, 1, RECV_BUF_SIZE); break;
case 'c': count = atoi(optarg); check_range(c, optarg, 1, 0); break;
case 'r': routing_only = 1; break;
case 's': stats = 1; break;
case 'v': verbose++; break;
case 'h':
printf(
"testPsyc -f <filename> [-b <read_buf_size>] [-c <count>] [-mnqrSsvP]\n"
"testPsyc [-p <port>] [-b <recv_buf_size>] [-nqrsvP]\n"
" -f <filename>\tInput file name\n"
" -p <port>\t\tListen on TCP port, default is %s\n"
" -b <buf_size>\tRead/receive buffer size, default is %d\n"
" -c <count>\t\tParse data from file <count> times\n"
" -r\t\t\tParse routing header only\n"
" -s\t\t\tShow statistics at the end\n"
" -h\t\t\tShow this help\n"
" -v\t\t\tVerbose\n",
port, RECV_BUF_SIZE);
exit(0);
case '?': exit(-1);
default: abort();
}
}
if (filename)
test_file(filename, count, recv_buf_size);
else
test_server(port, count, recv_buf_size);
return 0;
}