问题
In HP LoadRunner Analysis, there is a running vusers graph that shows the current number of virtual users that are running throughout the test. An example graph is shown below.
Does anyone know what is the SQL used to create the data for this graph? I know the data is stored in the LoadRunner analysis MDB database directly? ie An_Session1.mdb, though I am unable to determine the SQL Query.
Thanks
回答1:
I've refined the query a bit so I post a new answer instead of editing the previous one.
This produces columns that contain the CUMULATIVE count of vusers for a specific action over time. Please note that the output is not linear, it only contains a row when something has happened (x-axis).
SELECT
M.[End Time] AS RelTimeSec,
M.[VUser ID] AS VuserID,
M.[VUser Status ID] AS StatusID,
S.[Vuser Status Name],
( SELECT
Count( VuserEvent_Meter.[VUser Status ID] )
FROM
VuserEvent_Meter
WHERE
VuserEvent_Meter.[InOut Flag]=1 AND
VuserEvent_Meter.[End Time]<=M.[End Time] AND
VuserEvent_Meter.[VUser ID]>0 AND
VuserEvent_Meter.[VUser Status ID]=1
) AS CumulReady,
( SELECT
Count( VuserEvent_Meter.[VUser Status ID] )
FROM
VuserEvent_Meter
WHERE
VuserEvent_Meter.[InOut Flag]=1 AND
VuserEvent_Meter.[End Time]<=M.[End Time] AND
VuserEvent_Meter.[VUser ID]>0 AND
VuserEvent_Meter.[VUser Status ID]=2
) AS CumulRun,
( SELECT
Count( VuserEvent_Meter.[VUser Status ID] )
FROM
VuserEvent_Meter
WHERE
VuserEvent_Meter.[InOut Flag]=1 AND
VuserEvent_Meter.[End Time]<=M.[End Time] AND
VuserEvent_Meter.[VUser ID]>0 AND
VuserEvent_Meter.[VUser Status ID]=3
) AS CumulPause,
( SELECT
Count( VuserEvent_Meter.[VUser Status ID] )
FROM
VuserEvent_Meter
WHERE
VuserEvent_Meter.[InOut Flag]=1 AND
VuserEvent_Meter.[End Time]<=M.[End Time] AND
VuserEvent_Meter.[VUser ID]>0 AND
VuserEvent_Meter.[VUser Status ID]=4
) AS CumulQuit
FROM
VuserEvent_Meter M
INNER JOIN
VuserStatus S ON M.[VUser Status ID] = S.[Vuser Status ID]
WHERE
M.[InOut Flag]=1 AND M.[VUser Status ID] IN (1,2,3,4) AND M.[VUser ID]>0
ORDER BY
M.[End Time]
Outputs something like:
RelTimeSec VuserID StatusID Vuser Status Name CumulReady CumulRun CumulPause CumulQuit
15 1 2 Run 1 1 0 0
15 1 1 Ready 1 1 0 0
30 2 2 Run 2 2 0 0
30 2 1 Ready 2 2 0 0
45 3 1 Ready 3 3 0 0
45 3 2 Run 3 3 0 0
60 4 2 Run 4 4 0 0
60 4 1 Ready 4 4 0 0
75 5 1 Ready 5 5 0 0
75 5 2 Run 5 5 0 0
90 6 2 Run 6 6 0 0
90 6 1 Ready 6 6 0 0
...
1687 88 4 Quit 82 82 0 19
1687 86 4 Quit 82 82 0 19
1687 85 4 Quit 82 82 0 19
1687 87 4 Quit 82 82 0 19
1697 113 2 Run 83 83 0 19
1697 113 1 Ready 83 83 0 19
1712 114 1 Ready 84 84 0 19
1712 114 2 Run 84 84 0 19
1727 115 1 Ready 85 85 0 19
1727 115 2 Run 85 85 0 19
1742 116 2 Run 86 86 0 19
1742 116 1 Ready 86 86 0 19
1747 89 4 Quit 86 86 0 23
回答2:
I assume you mean the analysed results in this case.
If you open the .mdb file and have a look at the "VuserEvent_meter" table you will find all the needed data there.
It references the VuserStatus table for what the exact event was. Here's the SQL (written in Access):
SELECT
[M.End Time] AS RelTimeSec, [M.VUser ID] AS VuserID, [M.VUser Status ID] AS StatusID
FROM
VuserEvent_Meter M
WHERE
[M.InOut Flag]=1 AND [M.VUser Status ID]>0 AND [M.VUser ID]>0
ORDER BY
[M.End Time]
If you want to include the actual event name then you need to JOIN the [VuserStatus.Vuser Status Name] column, based on the [M.VUser Status ID] = [VuserStatus.Vuser Status ID].
I hope this points you in the right direction.
来源:https://stackoverflow.com/questions/8221424/what-is-the-sql-used-to-create-the-running-vusers-graph-in-loadrunner-analysis