1 /* echo.c - Command to display a line of text */
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2011 Free Software Foundation, Inc.
6 * GRUB is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GRUB is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
20 #include <grub/time.h>
21 #include <grub/misc.h>
23 #include <grub/command.h>
24 #include <grub/i18n.h>
26 GRUB_MOD_LICENSE ("GPLv3+");
30 grub_cmd_time (grub_command_t ctxt
__attribute__ ((unused
)),
31 int argc
, char **args
)
38 return grub_error (GRUB_ERR_BAD_ARGUMENT
, N_("no command is specified"));
40 cmd
= grub_command_find (args
[0]);
43 return grub_error (GRUB_ERR_UNKNOWN_COMMAND
, N_("can't find command `%s'"),
46 start
= grub_get_time_ms ();
47 (cmd
->func
) (cmd
, argc
- 1, &args
[1]);
48 end
= grub_get_time_ms ();
50 grub_printf_ (N_("Elapsed time: %d.%03d seconds \n"), (end
- start
) / 1000,
51 (end
- start
) % 1000);
56 static grub_command_t cmd
;
60 cmd
= grub_register_command ("time", grub_cmd_time
,
62 N_("Measure time used by COMMAND"));
67 grub_unregister_command (cmd
);