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
34610f31
Commit
34610f31
authored
Jul 15, 2018
by
Nick Craver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Profiling: move off database zero
parent
3d627197
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
Profiling.cs
StackExchange.Redis.Tests/Profiling.cs
+11
-10
No files found.
StackExchange.Redis.Tests/Profiling.cs
View file @
34610f31
...
@@ -41,7 +41,7 @@ public void Simple()
...
@@ -41,7 +41,7 @@ public void Simple()
var
i
=
0
;
var
i
=
0
;
foreach
(
var
cmd
in
cmds
)
foreach
(
var
cmd
in
cmds
)
{
{
Log
(
"Command {0}
: {1}"
,
i
++
,
cmd
.
ToString
().
Replace
(
"\n"
,
", "
));
Log
(
"Command {0}
(DB: {1}): {2}"
,
i
++,
cmd
.
Db
,
cmd
.
ToString
().
Replace
(
"\n"
,
", "
));
}
}
Log
(
"Checking for SET"
);
Log
(
"Checking for SET"
);
...
@@ -94,7 +94,7 @@ public void ManyThreads()
...
@@ -94,7 +94,7 @@ public void ManyThreads()
var
threads
=
new
List
<
Thread
>();
var
threads
=
new
List
<
Thread
>();
const
int
CountPer
=
100
;
const
int
CountPer
=
100
;
for
(
var
i
=
0
;
i
<
16
;
i
++)
for
(
var
i
=
1
;
i
<=
16
;
i
++)
{
{
var
db
=
conn
.
GetDatabase
(
i
);
var
db
=
conn
.
GetDatabase
(
i
);
...
@@ -116,8 +116,9 @@ public void ManyThreads()
...
@@ -116,8 +116,9 @@ public void ManyThreads()
threads
.
ForEach
(
thread
=>
thread
.
Join
());
threads
.
ForEach
(
thread
=>
thread
.
Join
());
var
allVals
=
conn
.
FinishProfiling
(
profiler
.
MyContext
);
var
allVals
=
conn
.
FinishProfiling
(
profiler
.
MyContext
);
var
relevant
=
allVals
.
Where
(
cmd
=>
cmd
.
Db
>
0
).
ToList
();
var
kinds
=
allVals
.
Select
(
cmd
=>
cmd
.
Command
).
Distinct
().
ToList
();
var
kinds
=
relevant
.
Select
(
cmd
=>
cmd
.
Command
).
Distinct
().
ToList
();
foreach
(
var
k
in
kinds
)
foreach
(
var
k
in
kinds
)
{
{
Log
(
"Kind Seen: "
+
k
);
Log
(
"Kind Seen: "
+
k
);
...
@@ -129,12 +130,12 @@ public void ManyThreads()
...
@@ -129,12 +130,12 @@ public void ManyThreads()
Assert
.
True
(
false
,
"Non-SET, Non-SELECT, Non-GET command seen"
);
Assert
.
True
(
false
,
"Non-SET, Non-SELECT, Non-GET command seen"
);
}
}
Assert
.
Equal
(
16
*
CountPer
,
allVals
.
Count
(
cmd
=>
cmd
.
Command
==
"SET"
)
);
Assert
.
Equal
(
16
*
CountPer
,
relevant
.
Count
);
Assert
.
Equal
(
16
,
allVals
.
Select
(
cmd
=>
cmd
.
Db
).
Distinct
().
Count
());
Assert
.
Equal
(
16
,
allVals
.
Select
(
cmd
=>
cmd
.
Db
).
Distinct
().
Count
());
for
(
var
i
=
0
;
i
<
16
;
i
++)
for
(
var
i
=
1
;
i
<=
16
;
i
++)
{
{
var
setsInDb
=
allVals
.
Count
(
cmd
=>
cmd
.
Db
==
i
&&
cmd
.
Command
==
"SET"
);
var
setsInDb
=
relevant
.
Count
(
cmd
=>
cmd
.
Db
==
i
);
Assert
.
Equal
(
CountPer
,
setsInDb
);
Assert
.
Equal
(
CountPer
,
setsInDb
);
}
}
}
}
...
@@ -427,7 +428,7 @@ public void LowAllocationEnumerable()
...
@@ -427,7 +428,7 @@ public void LowAllocationEnumerable()
conn
.
BeginProfiling
(
profiler
.
MyContext
);
conn
.
BeginProfiling
(
profiler
.
MyContext
);
var
prefix
=
Me
();
var
prefix
=
Me
();
var
db
=
conn
.
GetDatabase
();
var
db
=
conn
.
GetDatabase
(
1
);
var
allTasks
=
new
List
<
Task
<
string
>>();
var
allTasks
=
new
List
<
Task
<
string
>>();
...
@@ -462,9 +463,9 @@ public void LowAllocationEnumerable()
...
@@ -462,9 +463,9 @@ public void LowAllocationEnumerable()
Assert
.
True
(
object
.
ReferenceEquals
(
i
,
j
));
Assert
.
True
(
object
.
ReferenceEquals
(
i
,
j
));
}
}
Assert
.
Equal
(
OuterLoop
,
res
.
Count
(
r
=>
r
.
Command
==
"GET"
));
Assert
.
Equal
(
OuterLoop
,
res
.
Count
(
r
=>
r
.
Command
==
"GET"
&&
r
.
Db
>
0
));
Assert
.
Equal
(
OuterLoop
,
res
.
Count
(
r
=>
r
.
Command
==
"SET"
));
Assert
.
Equal
(
OuterLoop
,
res
.
Count
(
r
=>
r
.
Command
==
"SET"
&&
r
.
Db
>
0
));
Assert
.
Equal
(
OuterLoop
*
2
,
res
.
Count
());
Assert
.
Equal
(
OuterLoop
*
2
,
res
.
Count
(
r
=>
r
.
Db
>
0
));
}
}
}
}
...
...
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