1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:57:35 +00:00

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/stat.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#include <AK/FileSystemPath.h> #include <AK/FileSystemPath.h>
#include <LibCore/CElapsedTimer.h>
//#define SH_DEBUG //#define SH_DEBUG
@ -338,6 +339,19 @@ private:
Vector<int, 32> m_fds; 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) static int runcmd(char* cmd)
{ {
if (cmd[0] == 0) if (cmd[0] == 0)
@ -423,6 +437,8 @@ static int runcmd(char* cmd)
Vector<pid_t> children; Vector<pid_t> children;
CommandTimer timer;
for (int i = 0; i < subcommands.size(); ++i) { for (int i = 0; i < subcommands.size(); ++i) {
auto& subcommand = subcommands[i]; auto& subcommand = subcommands[i];
Vector<const char*> argv; Vector<const char*> argv;