Fossil SCM

Added fossil_timer_is_active(timerId), removed fossil_has_timer().

stephan 2013-05-08 19:54 trunk
Commit 590406df3c5cb6da25a736354a7e95aada071a7c
2 files changed +5 -2 +8 -3
+5 -2
--- src/json.c
+++ src/json.c
@@ -1424,23 +1424,26 @@
14241424
cson_object_set( o, "cmd.offset", tmp );
14251425
cson_object_set( o, "isCGI", cson_value_new_bool( g.isHTTP ) );
14261426
}
14271427
}
14281428
1429
- if(fossil_has_timer()){
1429
+ if(fossil_timer_is_active(g.json.timerId)){
14301430
/* This is, philosophically speaking, not quite the right place
14311431
for ending the timer, but this is the one function which all of
14321432
the JSON exit paths use (and they call it after processing,
14331433
just before they end).
14341434
*/
1435
- sqlite3_uint64 span = fossil_timer_fetch(g.json.timerId);
1435
+ sqlite3_uint64 span = fossil_timer_stop(g.json.timerId);
14361436
/* I'm actually seeing sub-uSec runtimes in some tests, but a time of
14371437
0 is "just kinda wrong".
14381438
*/
14391439
cson_object_set(o,"procTimeUs", cson_value_new_integer((cson_int_t)span));
14401440
span /= 1000/*for milliseconds */;
14411441
cson_object_set(o,"procTimeMs", cson_value_new_integer((cson_int_t)span));
1442
+ assert(!fossil_timer_is_active(g.json.timerId));
1443
+ g.json.timerId = -1;
1444
+
14421445
}
14431446
if(g.json.warnings){
14441447
tmp = cson_array_value(g.json.warnings);
14451448
SET("warnings");
14461449
}
14471450
--- src/json.c
+++ src/json.c
@@ -1424,23 +1424,26 @@
1424 cson_object_set( o, "cmd.offset", tmp );
1425 cson_object_set( o, "isCGI", cson_value_new_bool( g.isHTTP ) );
1426 }
1427 }
1428
1429 if(fossil_has_timer()){
1430 /* This is, philosophically speaking, not quite the right place
1431 for ending the timer, but this is the one function which all of
1432 the JSON exit paths use (and they call it after processing,
1433 just before they end).
1434 */
1435 sqlite3_uint64 span = fossil_timer_fetch(g.json.timerId);
1436 /* I'm actually seeing sub-uSec runtimes in some tests, but a time of
1437 0 is "just kinda wrong".
1438 */
1439 cson_object_set(o,"procTimeUs", cson_value_new_integer((cson_int_t)span));
1440 span /= 1000/*for milliseconds */;
1441 cson_object_set(o,"procTimeMs", cson_value_new_integer((cson_int_t)span));
 
 
 
1442 }
1443 if(g.json.warnings){
1444 tmp = cson_array_value(g.json.warnings);
1445 SET("warnings");
1446 }
1447
--- src/json.c
+++ src/json.c
@@ -1424,23 +1424,26 @@
1424 cson_object_set( o, "cmd.offset", tmp );
1425 cson_object_set( o, "isCGI", cson_value_new_bool( g.isHTTP ) );
1426 }
1427 }
1428
1429 if(fossil_timer_is_active(g.json.timerId)){
1430 /* This is, philosophically speaking, not quite the right place
1431 for ending the timer, but this is the one function which all of
1432 the JSON exit paths use (and they call it after processing,
1433 just before they end).
1434 */
1435 sqlite3_uint64 span = fossil_timer_stop(g.json.timerId);
1436 /* I'm actually seeing sub-uSec runtimes in some tests, but a time of
1437 0 is "just kinda wrong".
1438 */
1439 cson_object_set(o,"procTimeUs", cson_value_new_integer((cson_int_t)span));
1440 span /= 1000/*for milliseconds */;
1441 cson_object_set(o,"procTimeMs", cson_value_new_integer((cson_int_t)span));
1442 assert(!fossil_timer_is_active(g.json.timerId));
1443 g.json.timerId = -1;
1444
1445 }
1446 if(g.json.warnings){
1447 tmp = cson_array_value(g.json.warnings);
1448 SET("warnings");
1449 }
1450
+8 -3
--- src/util.c
+++ src/util.c
@@ -285,10 +285,15 @@
285285
return rc;
286286
}
287287
}
288288
289289
/*
290
-** Returns 1 if fossil has timer capabilities.
290
+** Returns true (non-0) if the given timer ID (as returned from
291
+** fossil_timer_start() is currently active.
291292
*/
292
-int fossil_has_timer(){
293
- return 1;
293
+int fossil_timer_is_active( int timerId ){
294
+ if(timerId<0 || timerId>=FOSSIL_TIMER_COUNT){
295
+ return 0;
296
+ }else{
297
+ return fossilTimerList[timerId].used;
298
+ }
294299
}
295300
--- src/util.c
+++ src/util.c
@@ -285,10 +285,15 @@
285 return rc;
286 }
287 }
288
289 /*
290 ** Returns 1 if fossil has timer capabilities.
 
291 */
292 int fossil_has_timer(){
293 return 1;
 
 
 
 
294 }
295
--- src/util.c
+++ src/util.c
@@ -285,10 +285,15 @@
285 return rc;
286 }
287 }
288
289 /*
290 ** Returns true (non-0) if the given timer ID (as returned from
291 ** fossil_timer_start() is currently active.
292 */
293 int fossil_timer_is_active( int timerId ){
294 if(timerId<0 || timerId>=FOSSIL_TIMER_COUNT){
295 return 0;
296 }else{
297 return fossilTimerList[timerId].used;
298 }
299 }
300

Keyboard Shortcuts

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