Commit 67e697d6 authored by captainwong's avatar captainwong

add bench

parent f7fc7865
......@@ -14,7 +14,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dll_demo", "dll_demo\dll_de
{EF267749-DA49-433D-BF4E-742D4BC7F1DA} = {EF267749-DA49-433D-BF4E-742D4BC7F1DA}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csharp_dll_demo", "csharp_dll_demo\csharp_dll_demo.csproj", "{3381C5DE-57BF-425F-A3A6-B85DECF776D6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "csharp_dll_demo", "csharp_dll_demo\csharp_dll_demo.csproj", "{3381C5DE-57BF-425F-A3A6-B85DECF776D6}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bench", "bench\bench.vcxproj", "{01B919A1-174A-45E5-A2B5-B509BD66E91A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......@@ -78,6 +80,16 @@ Global
{3381C5DE-57BF-425F-A3A6-B85DECF776D6}.Release|x64.Build.0 = Release|Any CPU
{3381C5DE-57BF-425F-A3A6-B85DECF776D6}.Release|x86.ActiveCfg = Release|Any CPU
{3381C5DE-57BF-425F-A3A6-B85DECF776D6}.Release|x86.Build.0 = Release|Any CPU
{01B919A1-174A-45E5-A2B5-B509BD66E91A}.Debug|Any CPU.ActiveCfg = Debug|Win32
{01B919A1-174A-45E5-A2B5-B509BD66E91A}.Debug|x64.ActiveCfg = Debug|x64
{01B919A1-174A-45E5-A2B5-B509BD66E91A}.Debug|x64.Build.0 = Debug|x64
{01B919A1-174A-45E5-A2B5-B509BD66E91A}.Debug|x86.ActiveCfg = Debug|Win32
{01B919A1-174A-45E5-A2B5-B509BD66E91A}.Debug|x86.Build.0 = Debug|Win32
{01B919A1-174A-45E5-A2B5-B509BD66E91A}.Release|Any CPU.ActiveCfg = Release|Win32
{01B919A1-174A-45E5-A2B5-B509BD66E91A}.Release|x64.ActiveCfg = Release|x64
{01B919A1-174A-45E5-A2B5-B509BD66E91A}.Release|x64.Build.0 = Release|x64
{01B919A1-174A-45E5-A2B5-B509BD66E91A}.Release|x86.ActiveCfg = Release|Win32
{01B919A1-174A-45E5-A2B5-B509BD66E91A}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
#define DISABLE_JLIB_LOG2
#include "../include/ademco_packet.h"
#include <string.h>
#include <stdio.h>
#include <chrono>
#include <thread>
using namespace ademco;
using namespace std::chrono;
#ifdef _DEBUG
constexpr int TIMES = 10000;
#else
constexpr int TIMES = 100000;
#endif
char data[TIMES * 256];
static constexpr size_t MaxAdemcoId = 999999;
static constexpr size_t AdemcoIdSentinel = MaxAdemcoId + 1;
void ademcoPacketBench()
{
printf("\nademcoPacketBench...\n");
printf("generating data...\n");
//std::vector<char> data; data.reserve(TIMES * 100);
AdemcoPacket ap;
//char tmp[256];
size_t total_len = 0;
for (int i = 0; i < TIMES; i++) {
auto len = ap.make_hb(data + total_len, sizeof(data) - total_len, (i + 1) % 10000, std::to_string(i), (i + 1) % AdemcoIdSentinel, 0, EVENT_ARM, 0);
assert(len > 0);
total_len += len;
if ((i + 1) % 1000 == 0) {
printf("\r%d/%d %s", i + 1, TIMES, ap.timestamp_.data_);
std::this_thread::sleep_for(milliseconds(15));
}
}
printf("\ndone\ntesting parse...\n");
auto start = steady_clock::now();
size_t cb = 0;
auto res = ap.parse(&data[0], total_len, cb);
assert(res == ParseResult::RESULT_OK);
size_t pos = 0;
int packets = 0;
while (res == ParseResult::RESULT_OK) {
packets++;
if (packets % 1000 == 0) {
printf("\r%d/%d %s", packets, TIMES, ap.timestamp_.data_);
}
pos += cb;
if (total_len > pos) {
res = ap.parse(&data[pos], total_len - pos, cb);
} else { break; }
}
assert(res == ParseResult::RESULT_OK);
assert(packets == TIMES);
auto duration = steady_clock::now() - start;
auto ms = duration_cast<milliseconds>(duration).count();
auto us = duration_cast<microseconds>(duration).count();
double avg = us * 1.0 / TIMES;
printf("\ndone\nduration=%lldms\navg parse time=%.2lfus\n", ms, avg);
double avgpps = 1000.0 * TIMES / ms;
printf("average packets per second=%.2lf\n", avgpps);
}
int main()
{
ademcoPacketBench();
system("pause");
}
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{01B919A1-174A-45E5-A2B5-B509BD66E91A}</ProjectGuid>
<RootNamespace>bench</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="bench.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="bench.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>
\ No newline at end of file
{
"version": 1,
"dgSpecHash": "FDUB06sqIrxY1NL2DCOnWir0yLn0cfS7UOQ3r27O7itJpNLP8ngEnZQ7woGolkt99yRPQK18ZL8ma5jkdqxccw==",
"dgSpecHash": "6CTziHR14vso8eK23U2BRvZk32JfFqH9GcXdXYIFBkA/95a748GIX77JI3JnOfn3R1p2/MR8a/UjDfwl0vxREw==",
"success": true
}
\ No newline at end of file
......@@ -42,16 +42,23 @@
"netcoreapp2.1": {
"dependencies": {
"Microsoft.NETCore.App": {
"suppressParent": "All",
"target": "Package",
"version": "[2.1.0, )",
"autoReferenced": true
}
},
"imports": [
"net461"
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true
"warn": true,
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.0.100\\RuntimeIdentifierGraph.json"
}
}
}
......
......@@ -7,7 +7,7 @@
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Jack\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.2.0</NuGetToolVersion>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.3.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
......
......@@ -729,16 +729,23 @@
"netcoreapp2.1": {
"dependencies": {
"Microsoft.NETCore.App": {
"suppressParent": "All",
"target": "Package",
"version": "[2.1.0, )",
"autoReferenced": true
}
},
"imports": [
"net461"
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true
"warn": true,
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.0.100\\RuntimeIdentifierGraph.json"
}
}
}
......
#pragma once
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <time.h>
#include <vector>
#include <memory>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment