8a14bfc57fd743b14842c8db206876779e3bc21b larrym Wed Aug 10 13:43:51 2011 -0700 move measureTiming output into span's so it can be manipulated on client side; add experimental dead code for returning image via URL (redmine #4888) diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c index 53043c4..72a23e5 100644 --- src/hg/hgTracks/hgTracks.c +++ src/hg/hgTracks/hgTracks.c @@ -2503,30 +2503,54 @@ jsonHashAddBoolean(jsonForClient, "inPlaceUpdate", IN_PLACE_UPDATE); if(rulerClickHeight) { jsonHashAddNumber(jsonForClient, "rulerClickHeight", rulerClickHeight); } if(newWinWidth) { jsonHashAddNumber(jsonForClient, "newWinWidth", newWinWidth); } /* Save out picture and tell html file about it. */ if(hvgSide != hvg) hvGfxClose(&hvgSide); hvGfxClose(&hvg); + +#ifdef SUPPORT_CONTENT_TYPE +// following is (currently dead) experimental code to bypass hgml and return png's directly - see redmine 4888 +if(sameString(cartUsualString(cart, "hgt.contentType", "html"), "png")) + { + char buf[4096]; + FILE *fd = fopen(gifTn.forCgi, "r"); + if(fd == NULL) + // fail some other way (e.g. HTTP 500)? + errAbort("Couldn't open png for reading"); + while(TRUE) + { + size_t n = fread(buf, 1, sizeof(buf), fd); + if(n) + fwrite(buf, 1, n, stdout); + else + break; + } + fclose(fd); + unlink(gifTn.forCgi); + return; + } +#endif + if(theImgBox) { imageBoxDraw(theImgBox); #ifdef IMAGEv2_DRAG_SCROLL // If a portal was established, then set the global dimensions back to the portal size if(imgBoxPortalDimensions(theImgBox,NULL,NULL,NULL,NULL,&winStart,&winEnd,&(tl.picWidth),NULL)) { pixWidth = tl.picWidth; winBaseCount = winEnd - winStart; insideWidth = tl.picWidth-gfxBorder-insideX; } #endif//def IMAGEv2_DRAG_SCROLL imgBoxFree(&theImgBox); } else @@ -4565,30 +4589,62 @@ char temp[256]; safef(temp, sizeof temp, "Timeout %d milliseconds exceeded processing %s", maxTimeInMilliseconds, pfd->track->track); pfd->track->networkErrMsg = cloneString(temp); ++errCount; } for (pfd = pfdDone; pfd; pfd = pfd->next) { // some done tracks may have errors if (pfd->track->networkErrMsg) ++errCount; } pthread_mutex_unlock( &pfdMutex ); return errCount; } +static void printTrackTiming() +{ +hPrintf("track, load time, draw time, total
\n"); +struct track *track; +for (track = trackList; track != NULL; track = track->next) + { + if (track->visibility == tvHide) + continue; + if (trackIsCompositeWithSubtracks(track)) //TODO: Change when tracks->subtracks are always set for composite + { + struct track *subtrack; + for (subtrack = track->subtracks; subtrack != NULL; + subtrack = subtrack->next) + if (isSubtrackVisible(subtrack)) + hPrintf("%s, %d, %d, %d
\n", subtrack->shortLabel, + subtrack->loadTime, subtrack->drawTime, + subtrack->loadTime + subtrack->drawTime); + } + else + { + hPrintf("%s, %d, %d, %d
\n", + track->shortLabel, track->loadTime, track->drawTime, + track->loadTime + track->drawTime); + if (startsWith("wigMaf", track->tdb->type)) + if (track->subtracks) + if (track->subtracks->loadTime) + hPrintf("    %s wiggle, load %d
\n", + track->shortLabel, track->subtracks->loadTime); + } + } +hPrintf("
\n"); +} void doTrackForm(char *psOutput, struct tempName *ideoTn) /* Make the tracks display form with the zoom/scroll buttons and the active * image. If the ideoTn parameter is not NULL, it is filled in if the * ideogram is created. */ { struct group *group; struct track *track; char *freezeName = NULL; boolean hideAll = cgiVarExists("hgt.hideAll"); boolean defaultTracks = cgiVarExists("hgt.reset"); boolean showedRuler = FALSE; boolean showTrackControls = cartUsualBoolean(cart, "trackControlsOnMain", TRUE); long thisTime = 0, lastTime = 0; @@ -4606,31 +4662,31 @@ withNextItemArrows = FALSE; withNextExonArrows = FALSE; hgFindMatches = NULL; } /* Tell browser where to go when they click on image. */ hPrintf("
\n\n", hgTracksName()); jsonHashAddNumber(jsonForClient, "insideX", insideX); jsonHashAddBoolean(jsonForClient, "revCmplDisp", revCmplDisp); #ifdef NEW_JQUERY hPrintf("\n"); #else///ifndef NEW_JQUERY hPrintf("\n"); #endif///ndef NEW_JQUERY -if (!psOutput) cartSaveSession(cart); +if (hPrintStatus()) cartSaveSession(cart); clearButtonJavascript = "document.TrackHeaderForm.position.value=''; document.getElementById('suggest').value='';"; /* See if want to include sequence search results. */ userSeqString = cartOptionalString(cart, "ss"); if (userSeqString && !ssFilesExist(userSeqString)) { userSeqString = NULL; cartRemove(cart, "ss"); } if (!hideControls) hideControls = cartUsualBoolean(cart, "hideControls", FALSE); if (measureTiming) measureTime("Time before getTrackList"); trackList = getTrackList(&groupList, defaultTracks ? -1 : -2); if (measureTiming) @@ -4967,32 +5023,38 @@ #ifdef IMAGEv2_DRAG_SCROLL if(!advancedJavascriptFeaturesEnabled(cart)) #endif//ndef IMAGEv2_DRAG_SCROLL hPrintf(">\n"); hPrintf(">>\n"); hPrintf(">>>\n"); hPrintf("\n"); #endif//def USE_NAVIGATION_LINKS /* Make clickable image and map. */ makeActiveImage(trackList, psOutput); fflush(stdout); if(trackImgOnly) + { // bail out b/c we are done + if (measureTiming) + { + printTrackTiming(); + } return; + } if (!hideControls) { struct controlGrid *cg = NULL; /* note a trick of WIDTH=27 going on here. The 6,15,6 widths following * go along with this trick */ hPrintf("\n", tl.picWidth, 27); #ifndef USE_NAVIGATION_LINKS hPrintf("
"); hPrintf("move start
"); #if IN_PLACE_UPDATE hButtonWithOnClick("hgt.dinkLL", " < ", "move start position to the left", "return navigateButtonClick(this);"); hTextVar("dinkL", cartUsualString(cart, "dinkL", "2.0"), 3); @@ -5208,59 +5270,32 @@ } else /* If track is not on this chrom print an informational message for the user. */ hPrintf("[No data-%s]", chromName); controlGridEndCell(cg); } /* now finish out the table */ if (group->next != NULL) controlGridEndRow(cg); } endControlGrid(&cg); } if (measureTiming) - { - hPrintf("track, load time, draw time, total
\n"); - for (track = trackList; track != NULL; track = track->next) - { - if (track->visibility == tvHide) - continue; - if (trackIsCompositeWithSubtracks(track)) //TODO: Change when tracks->subtracks are always set for composite - { - struct track *subtrack; - for (subtrack = track->subtracks; subtrack != NULL; - subtrack = subtrack->next) - if (isSubtrackVisible(subtrack)) - hPrintf("%s, %d, %d, %d
\n", subtrack->shortLabel, - subtrack->loadTime, subtrack->drawTime, - subtrack->loadTime + subtrack->drawTime); - } - else - { - hPrintf("%s, %d, %d, %d
\n", - track->shortLabel, track->loadTime, track->drawTime, - track->loadTime + track->drawTime); - if (startsWith("wigMaf", track->tdb->type)) - if (track->subtracks) - if (track->subtracks->loadTime) - hPrintf("    %s wiggle, load %d
\n", - track->shortLabel, track->subtracks->loadTime); - } - } - } + printTrackTiming(); + hPrintf("\n"); } if (showTrackControls) hButton("hgt.refresh", "refresh"); hPrintf("\n"); #ifdef SLOW /* We'll rely on the end of program to do the cleanup. * It turns out that the 'free' routine on Linux is * quite slow. For chromosome level views the browser * spends about 1/3 of it's time doing the cleanup * below if it's enabled. Since we really don't * need to reclaim this memory at this point I'm * taking this out. Please don't delete the code though. * I'll like to keep it for testing now and then. -jk. */ @@ -6018,20 +6053,21 @@ else if (cartVarExists(cart, configShowEncodeGroups)) { /* currently not used */ cartRemove(cart, configShowEncodeGroups); struct grp *grp = NULL, *grps = hLoadGrps(database); for (grp = grps; grp != NULL; grp = grp->next) if (startsWith("encode", grp->name)) collapseGroup(grp->name, FALSE); configPageSetTrackVis(-2); } else { tracksDisplay(); } +jsonHashAddBoolean(jsonForClient, "measureTiming", measureTiming); hPrintf("\n"); }