74009a95f1c1871f910292b98005957b328d3699
max
  Thu Jul 18 00:24:31 2024 -0700
fixing measureTiming in hgtracks for cart load time, refs #33932

diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c
index 3516b21..9793965 100644
--- src/hg/hgTracks/hgTracks.c
+++ src/hg/hgTracks/hgTracks.c
@@ -11196,39 +11196,44 @@
  * page, with the &pix=xxx variable added and return true. */
 return (isEmpty(cartOptionalString(cart, "pix")) && 
     !sameOk(cgiRequestMethod(NULL), "POST") && // page reload after POST would lose all vars
     !cartUsualBoolean(cart, "hgt.trackImgOnly", FALSE) && // skip if we're hgRenderTracks  = no Javascript
     !cgiWasSpoofed() && // we're not run from the command line
     !sameOk(cgiUserAgent(), "rtracklayer")); // rtracklayer has no javascript, so skip, see https://github.com/lawremi/rtracklayer/issues/113
 }
 
 extern boolean issueBotWarning;
 
 void doMiddle(struct cart *theCart)
 /* Print the body of an html file.   */
 {
 cart = theCart;
 
+measureTiming = hPrintStatus() && isNotEmpty(cartOptionalString(cart, "measureTiming"));
+
+if (measureTiming)
+    measureTime("Got cart: %d elements, userId=%s (=cookie), sessionId=%s", theCart->hash->elCount,
+	    theCart->userId, theCart->sessionId);
+
 if (noPixVariableSetAndInteractive())
 {
     jsIncludeFile("jquery.js", NULL);
     jsIncludeFile("utils.js", NULL);
     jsInlineF("addPixAndReloadPage();");
     return;
 }
 
-measureTiming = hPrintStatus() && isNotEmpty(cartOptionalString(cart, "measureTiming"));
 if (measureTiming)
     measureTime("Startup (bottleneck delay %d ms, not applied if under %d) ", botDelayMillis, hgBotDelayCurrWarnMs()) ;
 
 char *mouseOverEnabled = cfgOptionDefault("mouseOverEnabled", "on");
 if (sameWordOk(mouseOverEnabled, "on"))
     {
     /* can not use mouseOver in any virtual mode */
     char *isMultiRegion = cartUsualString(cart, "virtModeType", "default");
     if (sameWordOk(isMultiRegion, "default"))
 	{
 	enableMouseOver = TRUE;
 	/* mouseOverJsonFile will be initializes and created at the same
 	 * time as the browser .png image file
 	 */
 	mouseOverJson = jsonWriteNew();
@@ -11242,34 +11247,30 @@
 else
     enableMouseOver = FALSE;
 
 if (issueBotWarning)
     {
     char *ip = getenv("REMOTE_ADDR");
     botDelayMessage(ip, botDelayMillis);
     }
 
 // hide the link "Back to Genome Browser" in the "Genome Browser" menu, since we're on the genome browser now
 jsInline("$('#backToBrowserLi').remove();");
 
 char *debugTmp = NULL;
 /* Uncomment this to see parameters for debugging. */
 /* struct dyString *state = NULL; */
-/* Initialize layout and database. */
-if (measureTiming)
-    measureTime("Get cart of %d for user:%s session:%s", theCart->hash->elCount,
-	    theCart->userId, theCart->sessionId);
 /* #if 1 this to see parameters for debugging. */
 /* Be careful though, it breaks if custom track
  * is more than 4k */
 #if 0
 printf("State: %s\n", cgiUrlString()->string);
 #endif
 
 getDbAndGenome(cart, &database, &organism, oldVars);
 if (measureTiming)
     measureTime("before chromAliasSetup");
 chromAliasSetup(database);
 if (measureTiming)
     measureTime("after chromAliasSetup");
 
 genomeIsRna = !isHubTrack(database) && hgPdbOk(database);