Comments (9)
I'm not sure but It looks like GetInfoMessages is firing multiple times for the same connection/query so the elapsed/cpu times are counted more than once (so two messages with 2000 in one and 3000 in the later one = 5000 for that single query). You should be able to replicate by putting a breakpoint on the parsing code and running a test with 1 iteration and 1 thread
Proposed fix:
Track times by connection client ID in a dictionary so the value is only counted once. Then after each query completes allocate that to a global counter.
GetInfoMessages
` //we have times
if (matches.Length > 1)
{
var conn = (SqlConnection)sender;
var id = conn.ClientConnectionId;
//could probably add this to the connection creation area to tidy it up
if (!_outInfo.CpuTimes.TryGetValue(id, out var _))
{
_outInfo.CpuTimes.Add(conn.ClientConnectionId, 0);
_outInfo.ElapsedTimes.Add(conn.ClientConnectionId, 0);
}
//set the values for this connection to the last known amount
_outInfo.CpuTimes[id] = Convert.ToDouble(matches[1], CultureInfo.InvariantCulture);
_outInfo.ElapsedTimes[id] = Convert.ToDouble(matches[2], CultureInfo.InvariantCulture);
//_outInfo.CpuTime += Convert.ToInt32(matches[1], CultureInfo.InvariantCulture);
//_outInfo.ElapsedTime += Convert.ToInt32(matches[2], CultureInfo.InvariantCulture);
}`
And then QueryOutput updates
` public class QueryOutput
{
public double CpuTime => trackedCpu + CpuTimes.Values.Sum();
public Exception E;
public double ElapsedTime => trackedElapsedTime + ElapsedTimes.Values.Sum();
public bool Finished;
public int LogicalReads;
public TimeSpan Time;
public ConcurrentDictionary<Guid, double> CpuTimes = new();
public ConcurrentDictionary<Guid, double> ElapsedTimes = new();
private double trackedCpu = 0;
private double trackedElapsedTime = 0;
private object updateLock = new();
public void ClearTimes(Guid clientId)
{
lock (updateLock)
{
if (CpuTimes.TryGetValue(clientId, out double cpu))
CpuTimes[clientId] = 0;
if (ElapsedTimes.TryGetValue(clientId, out double elapsed))
ElapsedTimes[clientId] = 0;
trackedCpu += cpu;
trackedElapsedTime += elapsed;
}
}
...
`
And clear after each query:
//set up the statistics gathering if (_statsComm != null) { _statsComm.ExecuteNonQuery(); Thread.Sleep(0); _outInfo.ClearTimes(conn.ClientConnectionId); }
With these changes my results look more consistent.
I only saw the tool today so I'm not very familiar with it so if that explanation makes sense to you and you can duplicate the multi-message I'm happy to put a PR in with the changes next week when I get some time to tidy it up.
from sqlquerystress.
I also set the setting to true so that all the results are streamed to the client in the 2nd screenshot.
Although I think that isn't relevant give that all the numbers are about the same.
from sqlquerystress.
This is part if the original implementation, and not something I have touched the last 15 years. Maybe there is some info in the wiki?
from sqlquerystress.
Any updates?
from sqlquerystress.
Ideally the metrics displayed are accompanied by an explanation.
I favor a question mark that shows what it conveys when you have over it. This will be some work that I currently don't have the cycles for.
AFAIK there is no documentation that is reachable from the GUI. That would be a place for it as well.
from sqlquerystress.
Does this help? https://github.com/ErikEJ/SqlQueryStress/wiki
from sqlquerystress.
@DannyRichardsonWG Feel free to create a PR!
from sqlquerystress.
@DannyRichardsonWG Any plans to submit a PR?
from sqlquerystress.
@DannyRichardsonWG I am not able to reproduce the duplicate message events
from sqlquerystress.
Related Issues (20)
- localhost as default server name HOT 14
- label 1 2 3 is not a good practice HOT 2
- Selectable main query text HOT 4
- Launch a 'New Window' from GUI Application HOT 6
- Support Availability Group failover testing HOT 3
- Lift 200 thread limit HOT 1
- .NET 6.0 HOT 2
- Parameterizable database name? HOT 1
- [FeatureRequest] New Connection Per Iteration HOT 4
- [Request] Add stand alone download for sqlstresscmd HOT 3
- Can't use SQLQueryStress on servers with wildcard certificates HOT 9
- Add the ability to have MFA authentication - for Azure DBs HOT 8
- Update with hi res tip HOT 1
- The cmd version prints help text twice HOT 5
- Shouldn't a CHECKPOINT be performed before the DBCC DROPCLEANBUFFERS HOT 8
- Bundle the runtime with SQLQueryStress HOT 8
- Update to SqlClient 5.1.5
- Update to SqlClient 5.2.1 & publish new release HOT 1
- Consider future for Store publishing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlquerystress.