sh: Log to debugger how long command took.

This commit is contained in:
Andreas Kling
2019-05-02 02:22:28 +02:00
parent 9fa8324f7a
commit d3bd4fdcfe

View File

@@ -12,6 +12,7 @@
#include <sys/stat.h>
#include <sys/utsname.h>
#include <AK/FileSystemPath.h>
#include <LibCore/CElapsedTimer.h>
//#define SH_DEBUG
@@ -338,6 +339,19 @@ private:
Vector<int, 32> m_fds;
};
struct CommandTimer {
CommandTimer()
{
timer.start();
}
~CommandTimer()
{
dbgprintf("sh: command finished in %d ms\n", timer.elapsed());
}
CElapsedTimer timer;
};
static int runcmd(char* cmd)
{
if (cmd[0] == 0)
@@ -423,6 +437,8 @@ static int runcmd(char* cmd)
Vector<pid_t> children;
CommandTimer timer;
for (int i = 0; i < subcommands.size(); ++i) {
auto& subcommand = subcommands[i];
Vector<const char*> argv;