Modify "statistics dump" to dump JSON.
authorGreg Clayton <gclayton@fb.com>
Wed, 20 Oct 2021 21:49:09 +0000 (14:49 -0700)
committerGreg Clayton <gclayton@fb.com>
Thu, 21 Oct 2021 19:14:21 +0000 (12:14 -0700)
commitd7b338537cf360568474d31c2be86110ac22dc32
tree452bea87995e1af2dcdfad1a5f326b04cfd7f9b3
parent0472e83ffcc6c0506b0cd67844b97cb34eaa302e
Modify "statistics dump" to dump JSON.

This patch is a smaller version of a previous patch https://reviews.llvm.org/D110804.

This patch modifies the output of "statistics dump" to be able to get stats from the current target. It adds 3 new stats as well. The output of "statistics dump" is now emitted as JSON so that it can be used to track performance and statistics and the output could be used to populate a database that tracks performance. Sample output looks like:

(lldb) statistics dump
{
  "expressionEvaluation": {
    "failures": 0,
    "successes": 0
  },
  "firstStopTime": 0.34164492800000001,
  "frameVariable": {
    "failures": 0,
    "successes": 0
  },
  "launchOrAttachTime": 0.31969605400000001,
  "targetCreateTime": 0.0040863039999999998
}

The top level keys are:

"expressionEvaluation" which replaces the previous stats that were emitted as plain text. This dictionary contains the success and fail counts.
"frameVariable" which replaces the previous stats for "frame variable" that were emitted as plain text. This dictionary contains the success and fail counts.
"targetCreateTime" contains the number of seconds it took to create the target and load dependent libraries (if they were enabled) and also will contain symbol preloading times if that setting is enabled.
"launchOrAttachTime" is the time it takes from when the launch/attach is initiated to when the first private stop occurs.
"firstStopTime" is the time in seconds that it takes to stop at the first stop that is presented to the user via the LLDB interface. This value will only have meaning if you set a known breakpoint or stop location in your code that you want to measure as a performance test.

This diff is also meant as a place to discuess what we want out of the "statistics dump" command before adding more funcionality. It is also meant to clean up the previous code that was storting statistics in a vector of numbers within the lldb_private::Target class.

Differential Revision: https://reviews.llvm.org/D111686
15 files changed:
lldb/include/lldb/Target/Process.h
lldb/include/lldb/Target/Statistics.h [new file with mode: 0644]
lldb/include/lldb/Target/Target.h
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/source/API/SBTarget.cpp
lldb/source/Commands/CommandObjectExpression.cpp
lldb/source/Commands/CommandObjectFrame.cpp
lldb/source/Commands/CommandObjectStats.cpp
lldb/source/Commands/Options.td
lldb/source/Target/CMakeLists.txt
lldb/source/Target/Process.cpp
lldb/source/Target/Statistics.cpp [new file with mode: 0644]
lldb/source/Target/Target.cpp
lldb/test/API/commands/statistics/basic/TestStats.py
lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py