Upgraded GRUB2 to 2.00 release.
[AROS.git] / arch / all-pc / boot / grub2-aros / grub-core / commands / time.c
blob40d496e7ba0e78c655284473a25dbf6fcd572620
1 /* echo.c - Command to display a line of text */
2 /*
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>
22 #include <grub/dl.h>
23 #include <grub/command.h>
24 #include <grub/i18n.h>
26 GRUB_MOD_LICENSE ("GPLv3+");
29 static grub_err_t
30 grub_cmd_time (grub_command_t ctxt __attribute__ ((unused)),
31 int argc, char **args)
33 grub_command_t cmd;
34 grub_uint32_t start;
35 grub_uint32_t end;
37 if (argc == 0)
38 return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("no command is specified"));
40 cmd = grub_command_find (args[0]);
42 if (!cmd)
43 return grub_error (GRUB_ERR_UNKNOWN_COMMAND, N_("can't find command `%s'"),
44 args[0]);
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);
53 return grub_errno;
56 static grub_command_t cmd;
58 GRUB_MOD_INIT(time)
60 cmd = grub_register_command ("time", grub_cmd_time,
61 N_("COMMAND [ARGS]"),
62 N_("Measure time used by COMMAND"));
65 GRUB_MOD_FINI(time)
67 grub_unregister_command (cmd);