summaryrefslogtreecommitdiffstats
path: root/contrib/expat/tests/benchmark
diff options
context:
space:
mode:
authorcokane <cokane@FreeBSD.org>2008-05-08 13:51:16 +0000
committercokane <cokane@FreeBSD.org>2008-05-08 13:51:16 +0000
commiteef7fc6660961eb9e0913c4fe68b72df0f9fb8c3 (patch)
tree140a049e6dfd3941649feaf205e3a527a7543b00 /contrib/expat/tests/benchmark
parent676528b41eb1d7ef205f19c99dcb9585d9105d85 (diff)
downloadFreeBSD-src-eef7fc6660961eb9e0913c4fe68b72df0f9fb8c3.zip
FreeBSD-src-eef7fc6660961eb9e0913c4fe68b72df0f9fb8c3.tar.gz
Virgin import (trimmed) of eXpat v2.0.1. Discussed and tested with
sam and phk who are the two consumers of this library. If there is any other fallout, email me and I will take care of it. Approved by: sam, phk
Diffstat (limited to 'contrib/expat/tests/benchmark')
-rwxr-xr-xcontrib/expat/tests/benchmark/README.txt16
-rwxr-xr-xcontrib/expat/tests/benchmark/benchmark.c114
-rwxr-xr-xcontrib/expat/tests/benchmark/benchmark.dsp88
-rwxr-xr-xcontrib/expat/tests/benchmark/benchmark.dsw44
4 files changed, 262 insertions, 0 deletions
diff --git a/contrib/expat/tests/benchmark/README.txt b/contrib/expat/tests/benchmark/README.txt
new file mode 100755
index 0000000..7f9cca0
--- /dev/null
+++ b/contrib/expat/tests/benchmark/README.txt
@@ -0,0 +1,16 @@
+Use this benchmark command line utility as follows:
+
+ benchmark [-n] <file name> <buffer size> <# iterations>
+
+The command line arguments are:
+
+ -n ... optional; if supplied, namespace processing is turned on
+ <file name> ... name/path of test xml file
+ <buffer size> ... size of processing buffer;
+ the file is parsed in chunks of this size
+ <# iterations> ... how often will the file be parsed
+
+Returns:
+
+ The time (in seconds) it takes to parse the test file,
+ averaged over the number of iterations. \ No newline at end of file
diff --git a/contrib/expat/tests/benchmark/benchmark.c b/contrib/expat/tests/benchmark/benchmark.c
new file mode 100755
index 0000000..0f0fd18c
--- /dev/null
+++ b/contrib/expat/tests/benchmark/benchmark.c
@@ -0,0 +1,114 @@
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+#include "expat.h"
+
+#if defined(__amigaos__) && defined(__USE_INLINE__)
+#include <proto/expat.h>
+#endif
+
+#ifdef XML_LARGE_SIZE
+#define XML_FMT_INT_MOD "ll"
+#else
+#define XML_FMT_INT_MOD "l"
+#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 '%s' 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;
+}
diff --git a/contrib/expat/tests/benchmark/benchmark.dsp b/contrib/expat/tests/benchmark/benchmark.dsp
new file mode 100755
index 0000000..6f310d0a
--- /dev/null
+++ b/contrib/expat/tests/benchmark/benchmark.dsp
@@ -0,0 +1,88 @@
+# Microsoft Developer Studio Project File - Name="benchmark" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=benchmark - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "benchmark.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "benchmark.mak" CFG="benchmark - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "benchmark - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "benchmark - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "benchmark - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "..\..\lib" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x1009 /d "NDEBUG"
+# ADD RSC /l 0x1009 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+
+!ELSEIF "$(CFG)" == "benchmark - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\lib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x1009 /d "_DEBUG"
+# ADD RSC /l 0x1009 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "benchmark - Win32 Release"
+# Name "benchmark - Win32 Debug"
+# Begin Source File
+
+SOURCE=.\benchmark.c
+# End Source File
+# End Target
+# End Project
diff --git a/contrib/expat/tests/benchmark/benchmark.dsw b/contrib/expat/tests/benchmark/benchmark.dsw
new file mode 100755
index 0000000..3346a9a
--- /dev/null
+++ b/contrib/expat/tests/benchmark/benchmark.dsw
@@ -0,0 +1,44 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "benchmark"=.\benchmark.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name expat
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "expat"=..\..\lib\expat.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
OpenPOWER on IntegriCloud