Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StackExchange.Redis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
tsai
StackExchange.Redis
Commits
7a2e6b56
Commit
7a2e6b56
authored
Jul 02, 2018
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge
parent
1d8e9363
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
25 deletions
+27
-25
Program.cs
BasicTest/Program.cs
+14
-5
Program.cs
TestConsole/Program.cs
+13
-20
No files found.
BasicTest/Program.cs
View file @
7a2e6b56
...
...
@@ -6,6 +6,7 @@
using
BenchmarkDotNet.Diagnosers
;
using
BenchmarkDotNet.Jobs
;
using
BenchmarkDotNet.Running
;
using
BenchmarkDotNet.Toolchains.InProcess
;
using
BenchmarkDotNet.Validators
;
using
StackExchange.Redis
;
...
...
@@ -20,13 +21,14 @@ internal class CustomConfig : ManualConfig
public
CustomConfig
()
{
Job
Get
(
Job
j
)
=>
j
.
With
(
new
GcMode
{
Force
=
true
});
.
With
(
new
GcMode
{
Force
=
true
})
.
With
(
InProcessToolchain
.
Instance
);
Add
(
new
MemoryDiagnoser
());
Add
(
StatisticColumn
.
OperationsPerSecond
);
Add
(
JitOptimizationsValidator
.
FailOnError
);
Add
(
Get
(
Job
.
Clr
));
Add
(
Get
(
Job
.
Core
));
//
Add(Get(Job.Core));
}
}
/// <summary>
...
...
@@ -35,19 +37,26 @@ public CustomConfig()
[
Config
(
typeof
(
CustomConfig
))]
public
class
RedisBenchmarks
:
IDisposable
{
private
ConnectionMultiplexer
connection
;
private
IDatabase
db
;
SocketManager
mgr
;
ConnectionMultiplexer
connection
;
IDatabase
db
;
/// <summary>
/// Create
/// </summary>
public
RedisBenchmarks
()
{
connection
=
ConnectionMultiplexer
.
Connect
(
"127.0.0.1:6379,syncTimeout=200000"
);
mgr
=
new
SocketManager
(
GetType
().
Name
);
var
options
=
ConfigurationOptions
.
Parse
(
"127.0.0.1:6379,syncTimeout=1000"
);
options
.
SocketManager
=
mgr
;
connection
=
ConnectionMultiplexer
.
Connect
(
options
);
db
=
connection
.
GetDatabase
(
3
);
}
void
IDisposable
.
Dispose
()
{
mgr
?.
Dispose
();
connection
?.
Dispose
();
mgr
=
null
;
db
=
null
;
connection
=
null
;
}
...
...
TestConsole/Program.cs
View file @
7a2e6b56
using
System
;
using
System.Diagnostics
;
using
System.IO
;
using
System.Linq
;
using
StackExchange.Redis
;
namespace
TestConsole
...
...
@@ -24,11 +23,12 @@ private static int Main()
EndPoints
=
{
"127.0.0.1:6381"
},
Password
=
"abc"
,
};
using
(
var
conn
=
ConnectionMultiplexer
.
Connect
(
config
,
log
:
s
))
using
(
var
conn
=
ConnectionMultiplexer
.
Connect
(
config
,
log
:
Console
.
Out
))
{
Execute
(
conn
);
//Execute(conn);
}
Console
.
WriteLine
(
"Clean exit"
);
return
0
;
}
catch
(
Exception
ex
)
...
...
@@ -40,27 +40,20 @@ private static int Main()
{
watch
.
Stop
();
Console
.
WriteLine
();
Console
.
WriteLine
(
$"
{
watch
.
ElapsedMilliseconds
}
ms"
);
Console
.
WriteLine
();
//Console.WriteLine(s);
Console
.
ReadKey
();
Console
.
WriteLine
(
$"
{
watch
.
ElapsedMilliseconds
}
ms (done)"
);
}
}
private
static
void
Execute
(
ConnectionMultiplexer
conn
)
{
const
int
pageSize
=
100
;
RedisKey
key
=
nameof
(
Execute
);
var
db
=
conn
.
GetDatabase
();
db
.
KeyDelete
(
key
);
for
(
int
i
=
0
;
i
<
2000
;
i
++)
db
.
SetAdd
(
key
,
"s"
+
i
,
flags
:
CommandFlags
.
FireAndForget
);
int
count
=
db
.
SetScan
(
key
,
pageSize
:
pageSize
).
Count
();
Console
.
WriteLine
(
count
==
2000
?
"Pass"
:
"Fail"
);
var
key
=
"abc"
;
Console
.
ReadKey
();
var
db
=
conn
.
GetDatabase
(
0
);
var
t
=
db
.
CreateTransaction
();
t
.
HashSetAsync
(
key
,
"foo"
,
"bar"
);
t
.
KeyExpireAsync
(
key
,
TimeSpan
.
FromSeconds
(
3600
));
t
.
Execute
();
Console
.
ReadKey
();
}
}
}
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