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.

stephan 2013-07-17 09:23 UTC trunk
Commit 904a35d93b53eec3ffabf3fc7722e22b4cc896fc
1 file changed +22
--- src/th_main.c
+++ src/th_main.c
@@ -598,10 +598,31 @@
598598
sqlite3_snprintf(sizeof(zUTime), zUTime, "%llu", x);
599599
Th_SetResult(interp, zUTime, -1);
600600
return TH_OK;
601601
}
602602
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
+
603624
604625
/*
605626
** TH1 command: randhex N
606627
**
607628
** Return N*2 random hexadecimal digits with N<50. If N is omitted,
@@ -832,10 +853,11 @@
832853
{"puts", putsCmd, (void*)&aFlags[1]},
833854
{"query", queryCmd, 0},
834855
{"randhex", randhexCmd, 0},
835856
{"regexp", regexpCmd, 0},
836857
{"repository", repositoryCmd, 0},
858
+ {"runtime", runtimeCmd, 0},
837859
{"setting", settingCmd, 0},
838860
{"tclReady", tclReadyCmd, 0},
839861
{"stime", stimeCmd, 0},
840862
{"utime", utimeCmd, 0},
841863
{"wiki", wikiCmd, (void*)&aFlags[0]},
842864
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button