Using Program Arguments with perf with Terminal Window
-
I have a program which needs to start up in a terminal window and accept arguments at program entry (via the command line) and throughout the course of the program (think an interactive command line interface). I have my tools set up to accept the arguments, and it appears to not be acting on those arguments, additionally the program opens in the "Application Output" pane within Qt Creator rather than the terminal as specified in the "Projects" configuration.
Any solutions to this would be greatly appreciated.
-
@Alex-sw30
You should be able to access any command line arguments either via theargv
passed into yourmain(argc, argv)
or via Qt's ownQCommandLineParser
.throughout the course of the program (think an interactive command line interface).
I don't know what that means. Command line arguments come from the command line, not interactively. They are quite different from a program which accepts input on its stdin and acts on it, like e.g. a shell. That is not what "command line arguments" means.
additionally the program opens in the "Application Output" pane within Qt Creator rather than the terminal as specified in the "Projects" configuration.
I don't know what that means either. Programs don't "open" in the "Application Output" pane. Creator shows their output there if it's a UI program (when stdout wouldn't go anywhere), but not if it's a console one.
-
Alright, let me clear these points up:
The program is one which is intended to run solely in the terminal, or as a daemon.
The program operates on two sets of user inputs: the program input arguments (passed via flags and interpreted at the start via argv) and a CLI which operates as a shell of sorts. I have the program selected to "Run in terminal" and with Command line arguments. When running
perf
, neither of these seem to be obeyed.The program output (stdout, stderr) is directed to the "Application Output" pane. Additionally, there is an input prompt for the user,
>
which is expected to appear if the Command line arguments are accepted. This does not appear in the Application Output pane, indicating to me that Qt is neither obeying the request for command line arguments or for running in a terminal.Programs don't "open" in the "Application Output" pane.
Sorry, I said it this way to differentiate between the program running in terminal and appearing to be displayed in the "Application Output" pane.
-
@Alex-sw30 said in Using Program Arguments with perf with Terminal Window:
When running
perf
, neither of these seem to be obeyed.Assuming you mean the Linux
perf
, I have no idea how that (with a console window) interacts with Qt Creator, or fails to do so. I think you are saying it works fine run directly from a console, but not underperf
through Creator. You might tryperf
-ing it in a terminal, you don't have to do that from within Creator. As forperf
itself, good luck if you can understand any of its output or that shown in Creator. I tried it --- having been familiar with profilers likegprof
, and gave up after a day of trying to understand what it was trying to show me, which I found unintelligible! :)(And btw I have asked before in this forum about
perf
, got no answers, and discovered that the experts here do not profile their code. So I doubt you will get an answer aboutperf
.) -
Thanks for your input.
I find that the only truly helpful aspect of
perf
is the flame graph. I don't use it for profiling as much as understanding what is taking up the most amount of time in the code. If the code seems to run smoothly, great! But when things start to lag due to large amounts of calculations or unexpectedly repeated sections of code (think 100k+ line code base), I want to know where that lag comes from. -
@Alex-sw30
I agree with your sentiments entirely. The problem is that I couldn't understand whatperf
's flame graph was showing me any more than any of its other output! :) Whereas I used to understandgprof
fine.Anyway, as I said earlier: IF you are saying your code works fine outside of Qt Creator (or even from Creator) when you do not profile it, but then behaves oddly for I/O from/to console when you try to run from within Creator with profiling, I can only suggest you try
perf
directly from the terminal. I don't recall what/how, butperf
must have displayable output quite separate from Qt/Creator. I do not think you will get an answer here as to what your console app withperf
from Creator is not behaving right. Good luck though!