Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ademco_hb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
ademco_hb
Commits
8eec0067
Commit
8eec0067
authored
Sep 17, 2020
by
captainwong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bench client now only works in load test mode
parent
a49fafdf
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
628 additions
and
38 deletions
+628
-38
bench_client.cpp
examples/bench_client/bench_client.cpp
+14
-38
bench_client_ex.cpp
examples/bench_client_ex/bench_client_ex.cpp
+422
-0
bench_client_ex.vcxproj
examples/bench_client_ex/bench_client_ex.vcxproj
+150
-0
bench_client_ex.vcxproj.filters
examples/bench_client_ex/bench_client_ex.vcxproj.filters
+22
-0
bench_client_ex.vcxproj.user
examples/bench_client_ex/bench_client_ex.vcxproj.user
+4
-0
examples.sln
examples/examples.sln
+16
-0
No files found.
examples/bench_client/bench_client.cpp
View file @
8eec0067
...
...
@@ -52,7 +52,6 @@ uint64_t gettid() {
int
thread_count
=
0
;
int
session_count
=
0
;
int
session_connected
=
0
;
int
load_test
=
0
;
int
timeout
=
0
;
int
print_data
=
0
;
...
...
@@ -68,7 +67,7 @@ struct Session {
int
fd
=
0
;
int
thread_id
=
0
;
bufferevent
*
bev
=
nullptr
;
event
*
timer
=
nullptr
;
// life
or heartbeat
timer
event
*
timer
=
nullptr
;
// life timer
int
id
=
0
;
std
::
string
acct
=
{};
AdemcoId
ademco_id
=
0
;
...
...
@@ -110,7 +109,7 @@ void handle_ademco_msg(Session* session, bufferevent* bev)
auto
output
=
bufferevent_get_output
(
bev
);
switch
(
session
->
packet
.
id_
.
eid_
)
{
case
AdemcoMsgId
:
:
id_ack
:
if
(
load_test
)
{
{
auto
now
=
std
::
chrono
::
steady_clock
::
now
();
char
buf
[
1024
];
session
->
lastTimePacketSize
=
session
->
packet
.
make_null
(
buf
,
sizeof
(
buf
),
session
->
nextSeq
(),
session
->
acct
,
session
->
ademco_id
);
...
...
@@ -174,30 +173,11 @@ void timer_cb(evutil_socket_t, short, void* arg)
{
auto
session
=
(
Session
*
)
arg
;
if
(
load_test
)
{
printf
(
"session #%d timeout
\n
"
,
session
->
id
);
session
->
timer
=
nullptr
;
bufferevent_disable
(
session
->
bev
,
EV_WRITE
);
// SHUT_WR
shutdown
(
session
->
fd
,
1
);
}
else
{
session
->
timer
=
event_new
(
threadContexts
[
session
->
thread_id
]
->
base
,
-
1
,
0
,
timer_cb
,
session
);
if
(
!
session
->
timer
)
{
fprintf
(
stderr
,
"create heartbeat_timer failed
\n
"
);
event_base_loopbreak
(
threadContexts
[
session
->
thread_id
]
->
base
);
return
;
}
struct
timeval
heartbeat_tv
=
{
timeout
,
0
};
event_add
(
session
->
timer
,
&
heartbeat_tv
);
char
buf
[
1024
];
session
->
lastTimePacketSize
=
session
->
packet
.
make_null
(
buf
,
sizeof
(
buf
),
session
->
nextSeq
(),
session
->
acct
,
session
->
ademco_id
);
evbuffer_add
(
bufferevent_get_output
(
session
->
bev
),
buf
,
session
->
lastTimePacketSize
);
if
(
print_data
)
{
printf
(
"session #%d send:%s
\n
"
,
session
->
id
,
session
->
packet
.
toString
().
data
());
}
}
}
void
eventcb
(
struct
bufferevent
*
bev
,
short
events
,
void
*
user_data
)
...
...
@@ -343,11 +323,8 @@ int main(int argc, char** argv)
}
#endif
if
(
argc
<
7
)
{
printf
(
"Usage: %s ip port thread_count session_count load_test timeout [print_data]
\n
"
" load_test: 0 or 1:
\n
"
" 0 to disable load test mode, timeout is client's heartbeat timeout in seconds
\n
"
" 1 to enable load test mode, timeout is client's lifecycle timeout in seconds
\n
"
,
argv
[
0
]);
if
(
argc
<
6
)
{
printf
(
"Usage: %s ip port thread_count session_count timeout [print_data]
\n
"
,
argv
[
0
]);
return
1
;
}
...
...
@@ -375,20 +352,19 @@ int main(int argc, char** argv)
puts
(
"session_count must times thread_count"
);
return
1
;
}
load_test
=
atoi
(
argv
[
5
])
==
1
;
timeout
=
atoi
(
argv
[
6
]);
timeout
=
atoi
(
argv
[
5
]);
if
(
timeout
<=
0
)
{
puts
(
"Invalid timeout"
);
return
1
;
}
if
(
argc
>
7
)
{
print_data
=
atoi
(
argv
[
7
])
==
1
;
if
(
argc
>
6
)
{
print_data
=
atoi
(
argv
[
6
])
==
1
;
}
printf
(
"using libevent %s
\n
"
,
event_get_version
());
int
session_per_thread
=
session_count
/
thread_count
;
printf
(
"starting %s to %s:%d with %d threads, %d sessions, %d sessions per thread,
load_test is %s,
timeout=%ds
\n
"
,
argv
[
0
],
ip
,
port
,
thread_count
,
session_count
,
session_per_thread
,
load_test
?
"on"
:
"off"
,
timeout
);
printf
(
"starting %s to %s:%d with %d threads, %d sessions, %d sessions per thread, timeout=%ds
\n
"
,
argv
[
0
],
ip
,
port
,
thread_count
,
session_count
,
session_per_thread
,
timeout
);
sockaddr_in
sin
=
{
0
};
sin
.
sin_family
=
AF_INET
;
...
...
examples/bench_client_ex/bench_client_ex.cpp
0 → 100644
View file @
8eec0067
This diff is collapsed.
Click to expand it.
examples/bench_client_ex/bench_client_ex.vcxproj
0 → 100644
View file @
8eec0067
<?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>
<Keyword>
Win32Proj
</Keyword>
<ProjectGuid>
{12e806be-ba3e-452a-ab9d-09f4b379deb2}
</ProjectGuid>
<RootNamespace>
benchclientex
</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>
Unicode
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
Label=
"Configuration"
>
<ConfigurationType>
Application
</ConfigurationType>
<UseDebugLibraries>
false
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<CharacterSet>
Unicode
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
Label=
"Configuration"
>
<ConfigurationType>
Application
</ConfigurationType>
<UseDebugLibraries>
true
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<CharacterSet>
Unicode
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
Label=
"Configuration"
>
<ConfigurationType>
Application
</ConfigurationType>
<UseDebugLibraries>
false
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<CharacterSet>
Unicode
</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
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<LinkIncremental>
true
</LinkIncremental>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<LinkIncremental>
false
</LinkIncremental>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
<LinkIncremental>
true
</LinkIncremental>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
<LinkIncremental>
false
</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<SDLCheck>
true
</SDLCheck>
<PreprocessorDefinitions>
WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<ConformanceMode>
true
</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<SDLCheck>
true
</SDLCheck>
<PreprocessorDefinitions>
WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<ConformanceMode>
true
</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
<EnableCOMDATFolding>
true
</EnableCOMDATFolding>
<OptimizeReferences>
true
</OptimizeReferences>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<SDLCheck>
true
</SDLCheck>
<PreprocessorDefinitions>
_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<ConformanceMode>
true
</ConformanceMode>
<AdditionalIncludeDirectories>
$(SolutionDir)..\include;$(DEVLIBS)\libevent-2.1.12-stable-install-x64\include;%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
<AdditionalLibraryDirectories>
$(DEVLIBS)\libevent-2.1.12-stable-install-x64\lib;%(AdditionalLibraryDirectories)
</AdditionalLibraryDirectories>
<AdditionalDependencies>
event_core.lib;%(AdditionalDependencies)
</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<SDLCheck>
true
</SDLCheck>
<PreprocessorDefinitions>
NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<ConformanceMode>
true
</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
<EnableCOMDATFolding>
true
</EnableCOMDATFolding>
<OptimizeReferences>
true
</OptimizeReferences>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile
Include=
"bench_client_ex.cpp"
/>
</ItemGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
<ImportGroup
Label=
"ExtensionTargets"
>
</ImportGroup>
</Project>
\ No newline at end of file
examples/bench_client_ex/bench_client_ex.vcxproj.filters
0 → 100644
View file @
8eec0067
<?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;c++;cppm;ixx;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;h++;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_client_ex.cpp"
>
<Filter>
Source Files
</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
examples/bench_client_ex/bench_client_ex.vcxproj.user
0 → 100644
View file @
8eec0067
<?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
examples/examples.sln
View file @
8eec0067
...
...
@@ -40,6 +40,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "include", "include", "{332E
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "server_demo_libevent_linux", "server_demo_libevent_linux\server_demo_libevent_linux.vcxproj", "{7657FAE6-1ABF-45C3-AA89-ACAC1110C228}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bench_client_ex", "bench_client_ex\bench_client_ex.vcxproj", "{12E806BE-BA3E-452A-AB9D-09F4B379DEB2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
...
...
@@ -226,6 +228,20 @@ Global
{7657FAE6-1ABF-45C3-AA89-ACAC1110C228}.Release|x86.ActiveCfg = Release|x86
{7657FAE6-1ABF-45C3-AA89-ACAC1110C228}.Release|x86.Build.0 = Release|x86
{7657FAE6-1ABF-45C3-AA89-ACAC1110C228}.Release|x86.Deploy.0 = Release|x86
{12E806BE-BA3E-452A-AB9D-09F4B379DEB2}.Debug|Any CPU.ActiveCfg = Debug|Win32
{12E806BE-BA3E-452A-AB9D-09F4B379DEB2}.Debug|ARM.ActiveCfg = Debug|Win32
{12E806BE-BA3E-452A-AB9D-09F4B379DEB2}.Debug|ARM64.ActiveCfg = Debug|Win32
{12E806BE-BA3E-452A-AB9D-09F4B379DEB2}.Debug|x64.ActiveCfg = Debug|x64
{12E806BE-BA3E-452A-AB9D-09F4B379DEB2}.Debug|x64.Build.0 = Debug|x64
{12E806BE-BA3E-452A-AB9D-09F4B379DEB2}.Debug|x86.ActiveCfg = Debug|Win32
{12E806BE-BA3E-452A-AB9D-09F4B379DEB2}.Debug|x86.Build.0 = Debug|Win32
{12E806BE-BA3E-452A-AB9D-09F4B379DEB2}.Release|Any CPU.ActiveCfg = Release|Win32
{12E806BE-BA3E-452A-AB9D-09F4B379DEB2}.Release|ARM.ActiveCfg = Release|Win32
{12E806BE-BA3E-452A-AB9D-09F4B379DEB2}.Release|ARM64.ActiveCfg = Release|Win32
{12E806BE-BA3E-452A-AB9D-09F4B379DEB2}.Release|x64.ActiveCfg = Release|x64
{12E806BE-BA3E-452A-AB9D-09F4B379DEB2}.Release|x64.Build.0 = Release|x64
{12E806BE-BA3E-452A-AB9D-09F4B379DEB2}.Release|x86.ActiveCfg = Release|Win32
{12E806BE-BA3E-452A-AB9D-09F4B379DEB2}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment