diff options
author | Martin Sustrik <sustrik@250bpm.com> | 2011-04-02 09:50:35 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2011-04-02 09:50:35 +0200 |
commit | 85c2a84036675d40af47b57c410309da04ef742b (patch) | |
tree | e07fcafdca18ef698db291eed197497fb920fb6d | |
parent | 54830ac0f6869628e1e35cbae3434ca5e10ad600 (diff) |
inproc perf tests now work on Windows
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
-rw-r--r-- | builds/msvc/inproc_lat/inproc_lat.vcproj | 174 | ||||
-rw-r--r-- | builds/msvc/inproc_thr/inproc_thr.vcproj | 174 | ||||
-rw-r--r-- | builds/msvc/msvc.sln | 22 | ||||
-rw-r--r-- | perf/inproc_lat.cpp | 46 | ||||
-rw-r--r-- | perf/inproc_thr.cpp | 46 |
5 files changed, 458 insertions, 4 deletions
diff --git a/builds/msvc/inproc_lat/inproc_lat.vcproj b/builds/msvc/inproc_lat/inproc_lat.vcproj new file mode 100644 index 0000000..15549ff --- /dev/null +++ b/builds/msvc/inproc_lat/inproc_lat.vcproj @@ -0,0 +1,174 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="inproc_lat" + ProjectGUID="{6FF7436F-B3F6-4AE9-A3AC-CFDE8A3872A0}" + RootNamespace="inproc_lat" + TargetFrameworkVersion="196613" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + WarningLevel="3" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="../../../bin/inproc_lat.exe" + GenerateDebugInformation="true" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + CharacterSet="2" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + EnableIntrinsicFunctions="true" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + WarningLevel="3" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="../../../bin/inproc_lat.exe" + GenerateDebugInformation="true" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath="..\..\..\perf\inproc_lat.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/builds/msvc/inproc_thr/inproc_thr.vcproj b/builds/msvc/inproc_thr/inproc_thr.vcproj new file mode 100644 index 0000000..96415c9 --- /dev/null +++ b/builds/msvc/inproc_thr/inproc_thr.vcproj @@ -0,0 +1,174 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="inproc_thr" + ProjectGUID="{1077E977-95DD-4E73-A692-74647DD0CC1E}" + RootNamespace="inproc_thr" + TargetFrameworkVersion="196613" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + WarningLevel="3" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="../../../bin/inproc_thr.exe" + GenerateDebugInformation="true" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + CharacterSet="2" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + EnableIntrinsicFunctions="true" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + WarningLevel="3" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="../../../bin/inproc_thr.exe" + GenerateDebugInformation="true" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath="..\..\..\perf\inproc_thr.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/builds/msvc/msvc.sln b/builds/msvc/msvc.sln index 8d72dea..a79ec65 100644 --- a/builds/msvc/msvc.sln +++ b/builds/msvc/msvc.sln @@ -23,6 +23,16 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "remote_thr", "c_remote_thr\ {641C5F36-32EE-4323-B740-992B651CF9D6} = {641C5F36-32EE-4323-B740-992B651CF9D6} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "inproc_lat", "inproc_lat\inproc_lat.vcproj", "{6FF7436F-B3F6-4AE9-A3AC-CFDE8A3872A0}" + ProjectSection(ProjectDependencies) = postProject + {641C5F36-32EE-4323-B740-992B651CF9D6} = {641C5F36-32EE-4323-B740-992B651CF9D6} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "inproc_thr", "inproc_thr\inproc_thr.vcproj", "{1077E977-95DD-4E73-A692-74647DD0CC1E}" + ProjectSection(ProjectDependencies) = postProject + {641C5F36-32EE-4323-B740-992B651CF9D6} = {641C5F36-32EE-4323-B740-992B651CF9D6} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -60,6 +70,18 @@ Global {B15E059C-0CBB-4A82-8C42-6567FB650802}.Release|Win32.Build.0 = Release|Win32 {B15E059C-0CBB-4A82-8C42-6567FB650802}.WithOpenPGM|Win32.ActiveCfg = Release|Win32 {B15E059C-0CBB-4A82-8C42-6567FB650802}.WithOpenPGM|Win32.Build.0 = Release|Win32 + {6FF7436F-B3F6-4AE9-A3AC-CFDE8A3872A0}.Debug|Win32.ActiveCfg = Debug|Win32 + {6FF7436F-B3F6-4AE9-A3AC-CFDE8A3872A0}.Debug|Win32.Build.0 = Debug|Win32 + {6FF7436F-B3F6-4AE9-A3AC-CFDE8A3872A0}.Release|Win32.ActiveCfg = Release|Win32 + {6FF7436F-B3F6-4AE9-A3AC-CFDE8A3872A0}.Release|Win32.Build.0 = Release|Win32 + {6FF7436F-B3F6-4AE9-A3AC-CFDE8A3872A0}.WithOpenPGM|Win32.ActiveCfg = Release|Win32 + {6FF7436F-B3F6-4AE9-A3AC-CFDE8A3872A0}.WithOpenPGM|Win32.Build.0 = Release|Win32 + {1077E977-95DD-4E73-A692-74647DD0CC1E}.Debug|Win32.ActiveCfg = Debug|Win32 + {1077E977-95DD-4E73-A692-74647DD0CC1E}.Debug|Win32.Build.0 = Debug|Win32 + {1077E977-95DD-4E73-A692-74647DD0CC1E}.Release|Win32.ActiveCfg = Release|Win32 + {1077E977-95DD-4E73-A692-74647DD0CC1E}.Release|Win32.Build.0 = Release|Win32 + {1077E977-95DD-4E73-A692-74647DD0CC1E}.WithOpenPGM|Win32.ActiveCfg = Release|Win32 + {1077E977-95DD-4E73-A692-74647DD0CC1E}.WithOpenPGM|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/perf/inproc_lat.cpp b/perf/inproc_lat.cpp index f4e0eaa..ea4b5b1 100644 --- a/perf/inproc_lat.cpp +++ b/perf/inproc_lat.cpp @@ -24,19 +24,31 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> + +#include "../src/platform.hpp" + +#if defined ZMQ_HAVE_WINDOWS +#include <windows.h> +#include <process.h> +#else #include <pthread.h> +#endif static size_t message_size; static int roundtrip_count; -static void *worker (void *ctx) +#if defined ZMQ_HAVE_WINDOWS +static unsigned int __stdcall worker (void *ctx_) +#else +static void *worker (void *ctx_) +#endif { void *s; int rc; int i; zmq_msg_t msg; - s = zmq_socket (ctx, ZMQ_REP); + s = zmq_socket (ctx_, ZMQ_REP); if (!s) { printf ("error in zmq_socket: %s\n", zmq_strerror (errno)); exit (1); @@ -79,12 +91,20 @@ static void *worker (void *ctx) exit (1); } +#if defined ZMQ_HAVE_WINDOWS + return 0; +#else return NULL; +#endif } int main (int argc, char *argv []) { +#if defined ZMQ_HAVE_WINDOWS + HANDLE local_thread; +#else pthread_t local_thread; +#endif void *ctx; void *s; int rc; @@ -120,11 +140,20 @@ int main (int argc, char *argv []) return -1; } +#if defined ZMQ_HAVE_WINDOWS + local_thread = (HANDLE) _beginthreadex (NULL, 0, + worker, ctx, 0 , NULL); + if (local_thread == 0) { + printf ("error in _beginthreadex\n"); + return -1; + } +#else rc = pthread_create (&local_thread, NULL, worker, ctx); if (rc != 0) { printf ("error in pthread_create: %s\n", zmq_strerror (rc)); return -1; } +#endif rc = zmq_msg_init_size (&msg, message_size); if (rc != 0) { @@ -165,11 +194,24 @@ int main (int argc, char *argv []) latency = (double) elapsed / (roundtrip_count * 2); +#if defined ZMQ_HAVE_WINDOWS + DWORD rc2 = WaitForSingleObject (local_thread, INFINITE); + if (rc == WAIT_FAILED) { + printf ("error in WaitForSingleObject\n"); + return -1; + } + BOOL rc3 = CloseHandle (local_thread); + if (rc3 == 0) { + printf ("error in CloseHandle\n"); + return -1; + } +#else rc = pthread_join (local_thread, NULL); if (rc != 0) { printf ("error in pthread_join: %s\n", zmq_strerror (rc)); return -1; } +#endif printf ("average latency: %.3f [us]\n", (double) latency); diff --git a/perf/inproc_thr.cpp b/perf/inproc_thr.cpp index 57a5019..127257c 100644 --- a/perf/inproc_thr.cpp +++ b/perf/inproc_thr.cpp @@ -24,19 +24,31 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> + +#include "../src/platform.hpp" + +#if defined ZMQ_HAVE_WINDOWS +#include <windows.h> +#include <process.h> +#else #include <pthread.h> +#endif static int message_count; static size_t message_size; -static void *worker (void *ctx) +#if defined ZMQ_HAVE_WINDOWS +static unsigned int __stdcall worker (void *ctx_) +#else +static void *worker (void *ctx_) +#endif { void *s; int rc; int i; zmq_msg_t msg; - s = zmq_socket (ctx, ZMQ_PUB); + s = zmq_socket (ctx_, ZMQ_PUB); if (!s) { printf ("error in zmq_socket: %s\n", zmq_strerror (errno)); exit (1); @@ -77,12 +89,20 @@ static void *worker (void *ctx) exit (1); } +#if defined ZMQ_HAVE_WINDOWS + return 0; +#else return NULL; +#endif } int main (int argc, char *argv []) { +#if defined ZMQ_HAVE_WINDOWS + HANDLE local_thread; +#else pthread_t local_thread; +#endif void *ctx; void *s; int rc; @@ -125,11 +145,20 @@ int main (int argc, char *argv []) return -1; } +#if defined ZMQ_HAVE_WINDOWS + local_thread = (HANDLE) _beginthreadex (NULL, 0, + worker, ctx, 0 , NULL); + if (local_thread == 0) { + printf ("error in _beginthreadex\n"); + return -1; + } +#else rc = pthread_create (&local_thread, NULL, worker, ctx); if (rc != 0) { printf ("error in pthread_create: %s\n", zmq_strerror (rc)); return -1; } +#endif rc = zmq_msg_init (&msg); if (rc != 0) { @@ -174,11 +203,24 @@ int main (int argc, char *argv []) return -1; } +#if defined ZMQ_HAVE_WINDOWS + DWORD rc2 = WaitForSingleObject (local_thread, INFINITE); + if (rc == WAIT_FAILED) { + printf ("error in WaitForSingleObject\n"); + return -1; + } + BOOL rc3 = CloseHandle (local_thread); + if (rc3 == 0) { + printf ("error in CloseHandle\n"); + return -1; + } +#else rc = pthread_join (local_thread, NULL); if (rc != 0) { printf ("error in pthread_join: %s\n", zmq_strerror (rc)); return -1; } +#endif rc = zmq_close (s); if (rc != 0) { |