mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-12-01 23:24:21 +08:00
3de95038b0
In particular, this allows `true && time true`, or `true; and time true`, and both `time not true` as well as `not time true` (like bash). time is valid only as job _prefix_, so `true | time true` could call `/bin/time` (same in bash) See discussion in #6442
32 lines
623 B
C++
32 lines
623 B
C++
// Prototypes for executing builtin_time function.
|
|
#ifndef FISH_TIMER_H
|
|
#define FISH_TIMER_H
|
|
|
|
#include <sys/resource.h>
|
|
#include <sys/time.h>
|
|
#include <sys/types.h>
|
|
|
|
#include <chrono>
|
|
|
|
#include "common.h"
|
|
|
|
class parser_t;
|
|
struct io_streams_t;
|
|
|
|
cleanup_t push_timer(bool enabled);
|
|
|
|
struct timer_snapshot_t {
|
|
public:
|
|
struct rusage cpu_fish;
|
|
struct rusage cpu_children;
|
|
std::chrono::time_point<std::chrono::steady_clock> wall;
|
|
|
|
static timer_snapshot_t take();
|
|
static wcstring print_delta(timer_snapshot_t t1, timer_snapshot_t t2, bool verbose = false);
|
|
|
|
private:
|
|
timer_snapshot_t() {}
|
|
};
|
|
|
|
#endif
|