Fossil SCM
A th1 runtime command which returns the current value of fossil_timer_stop(g.json.timerId). Part of an old ML thread discussion. Probably not needed but maybe interesting.
Commit
904a35d93b53eec3ffabf3fc7722e22b4cc896fc
Parent
3a4f9ba6527671a…
1 file changed
+22
+22
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -598,10 +598,31 @@ | ||
| 598 | 598 | sqlite3_snprintf(sizeof(zUTime), zUTime, "%llu", x); |
| 599 | 599 | Th_SetResult(interp, zUTime, -1); |
| 600 | 600 | return TH_OK; |
| 601 | 601 | } |
| 602 | 602 | |
| 603 | +/* | |
| 604 | +** TH1 command: runtime | |
| 605 | +** | |
| 606 | +** Return the number of microseconds of CPU time consumed by the current | |
| 607 | +** process in both user and kernel space. | |
| 608 | +*/ | |
| 609 | +static int runtimeCmd( | |
| 610 | + Th_Interp *interp, | |
| 611 | + void *p, | |
| 612 | + int argc, | |
| 613 | + const char **argv, | |
| 614 | + int *argl | |
| 615 | +){ | |
| 616 | + char zUTime[50]; | |
| 617 | + sqlite3_uint64 x = fossil_timer_fetch(g.mainTimerId); | |
| 618 | + sqlite3_snprintf(sizeof(zUTime), zUTime, "%llu", x); | |
| 619 | + Th_SetResult(interp, zUTime, -1); | |
| 620 | + return TH_OK; | |
| 621 | +} | |
| 622 | + | |
| 623 | + | |
| 603 | 624 | |
| 604 | 625 | /* |
| 605 | 626 | ** TH1 command: randhex N |
| 606 | 627 | ** |
| 607 | 628 | ** Return N*2 random hexadecimal digits with N<50. If N is omitted, |
| @@ -832,10 +853,11 @@ | ||
| 832 | 853 | {"puts", putsCmd, (void*)&aFlags[1]}, |
| 833 | 854 | {"query", queryCmd, 0}, |
| 834 | 855 | {"randhex", randhexCmd, 0}, |
| 835 | 856 | {"regexp", regexpCmd, 0}, |
| 836 | 857 | {"repository", repositoryCmd, 0}, |
| 858 | + {"runtime", runtimeCmd, 0}, | |
| 837 | 859 | {"setting", settingCmd, 0}, |
| 838 | 860 | {"tclReady", tclReadyCmd, 0}, |
| 839 | 861 | {"stime", stimeCmd, 0}, |
| 840 | 862 | {"utime", utimeCmd, 0}, |
| 841 | 863 | {"wiki", wikiCmd, (void*)&aFlags[0]}, |
| 842 | 864 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -598,10 +598,31 @@ | |
| 598 | sqlite3_snprintf(sizeof(zUTime), zUTime, "%llu", x); |
| 599 | Th_SetResult(interp, zUTime, -1); |
| 600 | return TH_OK; |
| 601 | } |
| 602 | |
| 603 | |
| 604 | /* |
| 605 | ** TH1 command: randhex N |
| 606 | ** |
| 607 | ** Return N*2 random hexadecimal digits with N<50. If N is omitted, |
| @@ -832,10 +853,11 @@ | |
| 832 | {"puts", putsCmd, (void*)&aFlags[1]}, |
| 833 | {"query", queryCmd, 0}, |
| 834 | {"randhex", randhexCmd, 0}, |
| 835 | {"regexp", regexpCmd, 0}, |
| 836 | {"repository", repositoryCmd, 0}, |
| 837 | {"setting", settingCmd, 0}, |
| 838 | {"tclReady", tclReadyCmd, 0}, |
| 839 | {"stime", stimeCmd, 0}, |
| 840 | {"utime", utimeCmd, 0}, |
| 841 | {"wiki", wikiCmd, (void*)&aFlags[0]}, |
| 842 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -598,10 +598,31 @@ | |
| 598 | sqlite3_snprintf(sizeof(zUTime), zUTime, "%llu", x); |
| 599 | Th_SetResult(interp, zUTime, -1); |
| 600 | return TH_OK; |
| 601 | } |
| 602 | |
| 603 | /* |
| 604 | ** TH1 command: runtime |
| 605 | ** |
| 606 | ** Return the number of microseconds of CPU time consumed by the current |
| 607 | ** process in both user and kernel space. |
| 608 | */ |
| 609 | static int runtimeCmd( |
| 610 | Th_Interp *interp, |
| 611 | void *p, |
| 612 | int argc, |
| 613 | const char **argv, |
| 614 | int *argl |
| 615 | ){ |
| 616 | char zUTime[50]; |
| 617 | sqlite3_uint64 x = fossil_timer_fetch(g.mainTimerId); |
| 618 | sqlite3_snprintf(sizeof(zUTime), zUTime, "%llu", x); |
| 619 | Th_SetResult(interp, zUTime, -1); |
| 620 | return TH_OK; |
| 621 | } |
| 622 | |
| 623 | |
| 624 | |
| 625 | /* |
| 626 | ** TH1 command: randhex N |
| 627 | ** |
| 628 | ** Return N*2 random hexadecimal digits with N<50. If N is omitted, |
| @@ -832,10 +853,11 @@ | |
| 853 | {"puts", putsCmd, (void*)&aFlags[1]}, |
| 854 | {"query", queryCmd, 0}, |
| 855 | {"randhex", randhexCmd, 0}, |
| 856 | {"regexp", regexpCmd, 0}, |
| 857 | {"repository", repositoryCmd, 0}, |
| 858 | {"runtime", runtimeCmd, 0}, |
| 859 | {"setting", settingCmd, 0}, |
| 860 | {"tclReady", tclReadyCmd, 0}, |
| 861 | {"stime", stimeCmd, 0}, |
| 862 | {"utime", utimeCmd, 0}, |
| 863 | {"wiki", wikiCmd, (void*)&aFlags[0]}, |
| 864 |