+++ /dev/null
-#include <stdio.h>
-#include <sys/time.h>
-#include <libxml/xmlreader.h>
-
-void characters_cb
-(void * ctx, const xmlChar * ch, int len) { return; }
-
-void whitespace_cb
-(void *ctx, const xmlChar *ch, int len) { return; }
-
-void cdata_cb
-(void *ctx, const xmlChar *value, int len) { return; }
-
-void start_element_cb
-(void *ctx, const xmlChar *name, const xmlChar **atts) { return; }
-
-void start_element_ns_cb
-(void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI,
- int nb_namespaces, const xmlChar **namespaces, int nb_attributes,
- int nb_defaulted, const xmlChar **attributes)
-{ return; }
-
-void end_element_ns_cb
-(void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI)
-{ return; }
-
-void error_cb
-(void *ctx, const char *msg, ...) {
- fprintf(stderr, "Error: %s\n", msg);
- return;
-}
-
-int
-main(int argc, char *argv[])
-{
- char buf[BUFSIZ];
- int res;
- int done;
- FILE *xmlfile = stdin;
- struct timeval timing1, timing2;
- xmlParserCtxtPtr ctxt;
- xmlSAXHandler sax = {
- NULL, /* internalSubsetSAXFunc */
- NULL, /* isStandaloneSAXFunc */
- NULL, /* hasInternalSubsetSAXFunc */
- NULL, /* hasExternalSubsetSAXFunc */
- NULL, /* resolveEntitySAXFunc */
- NULL, /* getEntitySAXFunc */
- NULL, /* entityDeclSAXFunc */
- NULL, /* notationDeclSAXFunc */
- NULL, /* attributeDeclSAXFunc */
- NULL, /* elementDeclSAXFunc */
- NULL, /* unparsedEntityDeclSAXFunc */
- NULL, /* setDocumentLocatorSAXFunc */
- NULL, /* startDocumentSAXFunc */
- NULL, /* endDocumentSAXFunc */
- start_element_cb, /* startElementSAXFunc */
- NULL, /* endElementSAXFunc */
- NULL, /* referenceSAXFunc */
- characters_cb, /* charactersSAXFunc */
- whitespace_cb, /* ignorableWhitespaceSAXFunc */
- NULL, /* processingInstructionSAXFunc */
- NULL, /* commentSAXFunc */
- NULL, /* warningSAXFunc */
- error_cb, /* errorSAXFunc */
- NULL, /* fatalErrorSAXFunc */
- NULL, /* getParameterEntitySAXFunc */
- cdata_cb, /* cdataBlockSAXFunc */
- NULL, /* externalSubsetSAXFunc */
- XML_SAX2_MAGIC, /* initialized */
- NULL, /* _private */
- start_element_ns_cb, /* startElementNsSAX2Func */
- end_element_ns_cb, /* startElementNsSAX2Func */
- NULL /* xmlStructuredErrorFunc */
- };
- ctxt = xmlCreatePushParserCtxt(&sax, NULL, NULL, 0, NULL);
- if (ctxt == NULL) {
- fprintf(stderr, "Can't instantiate parser\n");
- return 1;
- }
- gettimeofday(&timing1, NULL);
- do {
- size_t len = fread(buf, 1, sizeof(buf), xmlfile);
- done = len < sizeof(buf);
- res = xmlParseChunk(ctxt, buf, len, 0);
- if (res != 0) {
- fprintf(stderr, "Parse error\n");
- return 1;
- }
- } while (!done);
- gettimeofday(&timing2, NULL);
- xmlFreeParserCtxt(ctxt);
- fprintf(stdout, "%d\n",
- ((timing2.tv_sec * 1000000 + timing2.tv_usec) -
- (timing1.tv_sec * 1000000 + timing1.tv_usec)) / 1000);
- return 0;
-}
-