[BACK]Return to benchmark.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / external / mit / expat / dist / tests / benchmark

File: [cvs.NetBSD.org] / src / external / mit / expat / dist / tests / benchmark / benchmark.c (download)

Revision 1.1.1.1.34.2, Tue Sep 17 18:50:06 2019 UTC (4 years, 7 months ago) by martin
Branch: netbsd-8
CVS Tags: netbsd-8-2-RELEASE
Changes since 1.1.1.1.34.1: +83 -48 lines

Sync external/mit/expat to current and pull up the following revisions,
requested by maya in ticket #1376:

	external/mit/expat/dist/conftools/test-driver	up to 1.1.1.1
	external/mit/expat/dist/conftools/ar-lib	up to 1.1.1.1
	external/mit/expat/dist/conftools/ax-append-compile-flags.m4 up to 1.1.1.1
	external/mit/expat/dist/conftools/ax-append-flag.m4 up to 1.1.1.1
	external/mit/expat/dist/conftools/ax-append-link-flags.m4 up to 1.1.1.1
	external/mit/expat/dist/conftools/ax-check-compile-flag.m4 up to 1.1.1.1
	external/mit/expat/dist/conftools/ax-check-link-flag.m4 up to 1.1.1.1
	external/mit/expat/dist/conftools/ax-require-defined.m4 up to 1.1.1.1
	external/mit/expat/dist/conftools/compile	up to 1.1.1.1
	external/mit/expat/dist/conftools/depcomp	up to 1.1.1.1
	external/mit/expat/dist/conftools/missing	up to 1.1.1.1
	external/mit/expat/dist/conftools/expatcfg-compiler-supports-visibility.m4 up to 1.1.1.1
	external/mit/expat/dist/doc/Makefile.am 	up to 1.1.1.1
	external/mit/expat/dist/doc/Makefile.in 	up to 1.1.1.1
	external/mit/expat/dist/examples/Makefile.am	up to 1.1.1.1
	external/mit/expat/dist/examples/Makefile.in	up to 1.1.1.1
	external/mit/expat/dist/lib/Makefile.am 	up to 1.1.1.1
	external/mit/expat/dist/lib/Makefile.in 	up to 1.1.1.1
	external/mit/expat/dist/tests/benchmark/Makefile.am up to 1.1.1.1
	external/mit/expat/dist/tests/benchmark/Makefile.in up to 1.1.1.1
	external/mit/expat/dist/tests/Makefile.am	up to 1.1.1.1
	external/mit/expat/dist/tests/Makefile.in	up to 1.1.1.1
	external/mit/expat/dist/tests/structdata.c	up to 1.1.1.1
	external/mit/expat/dist/tests/structdata.h	up to 1.1.1.1
	external/mit/expat/dist/tests/udiffer.py	up to 1.1.1.1
	external/mit/expat/dist/tests/xmltest.log.expected up to 1.1.1.1
	external/mit/expat/dist/win32/build_expat_iss.bat up to 1.1.1.1
	external/mit/expat/dist/xmlwf/Makefile.am	up to 1.1.1.1
	external/mit/expat/dist/xmlwf/Makefile.in	up to 1.1.1.1
	external/mit/expat/dist/xmlwf/xmlwf_helpgen.py	up to 1.1.1.1
	external/mit/expat/dist/xmlwf/xmlwf_helpgen.sh	up to 1.1.1.1
	external/mit/expat/dist/Makefile.am		up to 1.1.1.1
	external/mit/expat/dist/README.md		up to 1.1.1.1
	external/mit/expat/dist/cmake/expat-config.cmake.in up to 1.1.1.1
	external/mit/expat/dist/cmake/mingw-toolchain.cmake up to 1.1.1.1
	external/mit/expat/dist/acinclude.m4		up to 1.1.1.1
	external/mit/expat/dist/fix-xmltest-log.sh	up to 1.1.1.1
	external/mit/expat/dist/test-driver-wrapper.sh	up to 1.1.1.1
	external/mit/expat/dist/MANIFEST		delete
	external/mit/expat/dist/README			delete
	external/mit/expat/dist/conftools/ac_c_bigendian_cross.m4 delete
	external/mit/expat/dist/conftools/mkinstalldirs delete
	external/mit/expat/dist/xmlwf/xmlurl.h		delete
	external/mit/expat/dist/xmlwf/xmlwin32url.cxx	delete
	external/mit/expat/dist/CMake.README		up to 1.1.1.5
	external/mit/expat/dist/CMakeLists.txt		up to 1.1.1.5
	external/mit/expat/dist/Changes 		up to 1.1.1.6
	external/mit/expat/dist/ConfigureChecks.cmake	up to 1.1.1.2
	external/mit/expat/dist/Makefile.in		up to 1.1.1.6
	external/mit/expat/dist/aclocal.m4		up to 1.1.1.4
	external/mit/expat/dist/configure		up to 1.1.1.6
	external/mit/expat/dist/configure.ac		up to 1.1.1.4
	external/mit/expat/dist/expat_config.h.cmake	up to 1.1.1.2
	external/mit/expat/dist/expat_config.h.in	up to 1.1.1.6
	external/mit/expat/dist/conftools/config.guess	up to 1.4
	external/mit/expat/dist/conftools/config.sub	up to 1.4
	external/mit/expat/dist/conftools/get-version.sh up to 1.1.1.2
	external/mit/expat/dist/conftools/install-sh	up to 1.1.1.5
	external/mit/expat/dist/conftools/ltmain.sh	up to 1.1.1.5
	external/mit/expat/dist/doc/reference.html	up to 1.1.1.5
	external/mit/expat/dist/doc/xmlwf.1		up to 1.1.1.4
	external/mit/expat/dist/doc/xmlwf.xml		up to 1.1.1.2
	external/mit/expat/dist/examples/elements.c	up to 1.1.1.5
	external/mit/expat/dist/examples/outline.c	up to 1.1.1.4
	external/mit/expat/dist/lib/ascii.h		up to 1.1.1.2
	external/mit/expat/dist/lib/asciitab.h		up to 1.1.1.2
	external/mit/expat/dist/lib/expat.h		up to 1.1.1.6
	external/mit/expat/dist/lib/expat_external.h	up to 1.1.1.4
	external/mit/expat/dist/lib/iasciitab.h 	up to 1.1.1.2
	external/mit/expat/dist/lib/internal.h		up to 1.1.1.3
	external/mit/expat/dist/lib/latin1tab.h 	up to 1.1.1.2
	external/mit/expat/dist/lib/libexpat.def	up to 1.1.1.3
	external/mit/expat/dist/lib/libexpatw.def	up to 1.1.1.3
	external/mit/expat/dist/lib/nametab.h		up to 1.1.1.2
	external/mit/expat/dist/lib/siphash.h		up to 1.1.1.2
	external/mit/expat/dist/lib/utf8tab.h		up to 1.1.1.2
	external/mit/expat/dist/lib/winconfig.h 	up to 1.1.1.3
	external/mit/expat/dist/lib/xmlparse.c		up to 1.8
	external/mit/expat/dist/lib/xmlrole.c		up to 1.1.1.5
	external/mit/expat/dist/lib/xmlrole.h		up to 1.1.1.2
	external/mit/expat/dist/lib/xmltok.c		up to 1.5
	external/mit/expat/dist/lib/xmltok.h		up to 1.3
	external/mit/expat/dist/lib/xmltok_impl.c	up to 1.6
	external/mit/expat/dist/lib/xmltok_impl.h	up to 1.1.1.2
	external/mit/expat/dist/lib/xmltok_ns.c 	up to 1.1.1.2
	external/mit/expat/dist/tests/chardata.c	up to 1.1.1.4
	external/mit/expat/dist/tests/chardata.h	up to 1.1.1.2
	external/mit/expat/dist/tests/memcheck.c	up to 1.1.1.2
	external/mit/expat/dist/tests/memcheck.h	up to 1.1.1.2
	external/mit/expat/dist/tests/minicheck.c	up to 1.1.1.4
	external/mit/expat/dist/tests/minicheck.h	up to 1.1.1.5
	external/mit/expat/dist/tests/runtests.c	up to 1.1.1.5
	external/mit/expat/dist/tests/runtestspp.cpp	up to 1.1.1.2
	external/mit/expat/dist/tests/xmltest.sh	up to 1.4
	external/mit/expat/dist/tests/benchmark/benchmark.c up to 1.1.1.3
	external/mit/expat/dist/win32/README.txt	up to 1.1.1.5
	external/mit/expat/dist/win32/expat.iss 	up to 1.1.1.6
	external/mit/expat/dist/xmlwf/codepage.c	up to 1.1.1.4
	external/mit/expat/dist/xmlwf/codepage.h	up to 1.1.1.2
	external/mit/expat/dist/xmlwf/ct.c		up to 1.1.1.2
	external/mit/expat/dist/xmlwf/filemap.h 	up to 1.1.1.3
	external/mit/expat/dist/xmlwf/readfilemap.c	up to 1.1.1.5
	external/mit/expat/dist/xmlwf/unixfilemap.c	up to 1.1.1.4
	external/mit/expat/dist/xmlwf/win32filemap.c	up to 1.1.1.3
	external/mit/expat/dist/xmlwf/xmlfile.c 	up to 1.1.1.4
	external/mit/expat/dist/xmlwf/xmlfile.h 	up to 1.1.1.2
	external/mit/expat/dist/xmlwf/xmlmime.c 	up to 1.1.1.2
	external/mit/expat/dist/xmlwf/xmlmime.h         up to 1.1.1.2
	external/mit/expat/dist/xmlwf/xmltchar.h        up to 1.1.1.2
	external/mit/expat/dist/xmlwf/xmlwf.c           up to 1.1.1.6
	external/mit/expat/lib/libexpat/expat_config.h  up to 1.6
	doc/3RDPARTY					1.1649 (patch)
	external/mit/xorg/tools/fc-cache/Makefile	1.18 (patch)

Update expat to 2.2.8.
Define XML_POOR_ENTROPY for the tool version of fc-cache
(we can not assume anything about the build host).

/*
                            __  __            _
                         ___\ \/ /_ __   __ _| |_
                        / _ \\  /| '_ \ / _` | __|
                       |  __//  \| |_) | (_| | |_
                        \___/_/\_\ .__/ \__,_|\__|
                                 |_| XML parser

   Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
   Copyright (c) 2000-2017 Expat development team
   Licensed under the MIT license:

   Permission is  hereby granted,  free of charge,  to any  person obtaining
   a  copy  of  this  software   and  associated  documentation  files  (the
   "Software"),  to  deal in  the  Software  without restriction,  including
   without  limitation the  rights  to use,  copy,  modify, merge,  publish,
   distribute, sublicense, and/or sell copies of the Software, and to permit
   persons  to whom  the Software  is  furnished to  do so,  subject to  the
   following conditions:

   The above copyright  notice and this permission notice  shall be included
   in all copies or substantial portions of the Software.

   THE  SOFTWARE  IS  PROVIDED  "AS  IS",  WITHOUT  WARRANTY  OF  ANY  KIND,
   EXPRESS  OR IMPLIED,  INCLUDING  BUT  NOT LIMITED  TO  THE WARRANTIES  OF
   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
   NO EVENT SHALL THE AUTHORS OR  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
   DAMAGES OR  OTHER LIABILITY, WHETHER  IN AN  ACTION OF CONTRACT,  TORT OR
   OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
   USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "expat.h"

#ifdef XML_LARGE_SIZE
#  define XML_FMT_INT_MOD "ll"
#else
#  define XML_FMT_INT_MOD "l"
#endif

#ifdef XML_UNICODE_WCHAR_T
#  define XML_FMT_STR "ls"
#else
#  define XML_FMT_STR "s"
#endif

static void
usage(const char *prog, int rc) {
  fprintf(stderr, "usage: %s [-n] filename bufferSize nr_of_loops\n", prog);
  exit(rc);
}

int
main(int argc, char *argv[]) {
  XML_Parser parser;
  char *XMLBuf, *XMLBufEnd, *XMLBufPtr;
  FILE *fd;
  struct stat fileAttr;
  int nrOfLoops, bufferSize, fileSize, i, isFinal;
  int j = 0, ns = 0;
  clock_t tstart, tend;
  double cpuTime = 0.0;

  if (argc > 1) {
    if (argv[1][0] == '-') {
      if (argv[1][1] == 'n' && argv[1][2] == '\0') {
        ns = 1;
        j = 1;
      } else
        usage(argv[0], 1);
    }
  }

  if (argc != j + 4)
    usage(argv[0], 1);

  if (stat(argv[j + 1], &fileAttr) != 0) {
    fprintf(stderr, "could not access file '%s'\n", argv[j + 1]);
    return 2;
  }

  fd = fopen(argv[j + 1], "r");
  if (! fd) {
    fprintf(stderr, "could not open file '%s'\n", argv[j + 1]);
    exit(2);
  }

  bufferSize = atoi(argv[j + 2]);
  nrOfLoops = atoi(argv[j + 3]);
  if (bufferSize <= 0 || nrOfLoops <= 0) {
    fprintf(stderr, "buffer size and nr of loops must be greater than zero.\n");
    exit(3);
  }

  XMLBuf = malloc(fileAttr.st_size);
  fileSize = fread(XMLBuf, sizeof(char), fileAttr.st_size, fd);
  fclose(fd);

  if (ns)
    parser = XML_ParserCreateNS(NULL, '!');
  else
    parser = XML_ParserCreate(NULL);

  i = 0;
  XMLBufEnd = XMLBuf + fileSize;
  while (i < nrOfLoops) {
    XMLBufPtr = XMLBuf;
    isFinal = 0;
    tstart = clock();
    do {
      int parseBufferSize = XMLBufEnd - XMLBufPtr;
      if (parseBufferSize <= bufferSize)
        isFinal = 1;
      else
        parseBufferSize = bufferSize;
      if (! XML_Parse(parser, XMLBufPtr, parseBufferSize, isFinal)) {
        fprintf(stderr,
                "error '%" XML_FMT_STR "' at line %" XML_FMT_INT_MOD
                "u character %" XML_FMT_INT_MOD "u\n",
                XML_ErrorString(XML_GetErrorCode(parser)),
                XML_GetCurrentLineNumber(parser),
                XML_GetCurrentColumnNumber(parser));
        free(XMLBuf);
        XML_ParserFree(parser);
        exit(4);
      }
      XMLBufPtr += bufferSize;
    } while (! isFinal);
    tend = clock();
    cpuTime += ((double)(tend - tstart)) / CLOCKS_PER_SEC;
    XML_ParserReset(parser, NULL);
    i++;
  }

  XML_ParserFree(parser);
  free(XMLBuf);

  printf("%d loops, with buffer size %d. Average time per loop: %f\n",
         nrOfLoops, bufferSize, cpuTime / (double)nrOfLoops);
  return 0;
}