6eb7b642e4d1286b4662ea3d527a9bc09b17db70 kate Wed May 4 10:53:50 2016 -0700 Performance work: Add measureTiming support. Also, restructure GTEx to move heavy lifting to print routine so closing section will save time. Also, a few label changes for expression sections. refs #17244 diff --git src/hg/hgGene/hgGene.c src/hg/hgGene/hgGene.c index 7e0cc60..a023af9 100644 --- src/hg/hgGene/hgGene.c +++ src/hg/hgGene/hgGene.c @@ -27,30 +27,31 @@ /* ---- Global variables. ---- */ struct cart *cart; /* This holds cgi and other variables between clicks. */ struct hash *oldVars; /* Old cart hash. */ char *database; /* Name of genome database - hg15, mm3, or the like. */ char *genome; /* Name of genome - mouse, human, etc. */ char *curGeneId; /* Current Gene Id. */ char *curGeneName; /* Biological name of gene. */ char *curGeneChrom; /* Chromosome current gene is on. */ char *curAlignId; struct genePred *curGenePred; /* Current gene prediction structure. */ int curGeneStart,curGeneEnd; /* Position in chromosome. */ struct sqlConnection *spConn; /* Connection to SwissProt database. */ char *swissProtAcc; /* SwissProt accession (may be NULL). */ int kgVersion = KG_UNKNOWN; /* KG version */ +int measureTiming = FALSE; //#include "rgdInfo.c" void usage() /* Explain usage and exit. */ { errAbort( "hgGene - A CGI script to display the gene details page.\n" "usage:\n" " hgGene cgi-vars in var=val format\n" "options:\n" " -hgsid=XXX Session ID to grab vars from session database\n" " -db=XXX Genome database associated with gene\n" " -org=XXX Organism associated with gene\n" " -hgg_gene=XXX ID of gene\n" @@ -354,35 +355,40 @@ const struct section *a = *((struct section **)va); const struct section *b = *((struct section **)vb); float dif = a->priority - b->priority; if (dif < 0) return -1; else if (dif > 0) return 1; else return 0; } static void addGoodSection(struct section *section, struct sqlConnection *conn, struct section **pList) /* Add section to list if it is non-null and exists returns ok. */ { -//printf("
adding %s section \n", section->name);fflush(stdout); -if (section != NULL && hashLookup(section->settings, "hide") == NULL - && section->exists(section, conn, curGeneId)) +//uglyf("
adding %s section \n", section->name);fflush(stdout); +if (section == NULL || hashLookup(section->settings, "hide") != NULL) + return; +long startTime = clock1000(); +if (section->exists(section, conn, curGeneId)) + { + section->checkTime = clock1000() - startTime; slAddHead(pList, section); } +} struct section *loadSectionList(struct sqlConnection *conn) /* Load up section list - first load up sections.ra, and then * call each section loader. */ { struct hash *sectionRa = NULL; struct section *sectionList = NULL; readRa("section.ra", §ionRa); // Could be an ajax request for a single section! char *ajaxSection = cartOptionalString(cart, hggAjaxSection); if (ajaxSection != NULL) { // Currently only one section supports ajax update. @@ -398,31 +404,30 @@ if (!hIsCgbServer()) addGoodSection(otherOrgsSection(conn, sectionRa), conn, §ionList); addGoodSection(gadSection(conn, sectionRa), conn, §ionList); addGoodSection(malaCardsSection(conn, sectionRa), conn, §ionList); addGoodSection(ctdSection(conn, sectionRa), conn, §ionList); /*if (isRgdGene(conn)) { addGoodSection(ctdRgdGene2Section(conn, sectionRa), conn, §ionList); } else { addGoodSection(ctdSection(conn, sectionRa), conn, §ionList); } */ addGoodSection(rgdGeneRawSection(conn, sectionRa), conn, §ionList); -//addGoodSection(microarraySection(conn, sectionRa), conn, §ionList); addGoodSection(gtexSection(conn, sectionRa), conn, §ionList); /* temporarily disable microarray section for Zebrafish, until a bug is fixed */ if (strstr(database, "danRer") == NULL) { addGoodSection(microarraySection(conn, sectionRa), conn, §ionList); } addGoodSection(rnaStructureSection(conn, sectionRa), conn, §ionList); addGoodSection(domainsSection(conn, sectionRa), conn, §ionList); addGoodSection(altSpliceSection(conn, sectionRa), conn, §ionList); // addGoodSection(multipleAlignmentsSection(conn, sectionRa), conn, §ionList); addGoodSection(swissProtCommentsSection(conn, sectionRa), conn, §ionList); addGoodSection(flyBaseRolesSection(conn, sectionRa), conn, §ionList); addGoodSection(flyBasePhenotypesSection(conn, sectionRa), conn, §ionList); addGoodSection(flyBaseSynonymsSection(conn, sectionRa), conn, §ionList); addGoodSection(bdgpExprInSituSection(conn, sectionRa), conn, §ionList); @@ -492,51 +497,75 @@ char *closeVarName = sectionCloseVar(section->name); boolean isOpen = !(cartUsualInt(cart, closeVarName, 0)); char *otherState = (isOpen ? "1" : "0"); char *indicator = (isOpen ? "-" : "+"); char *indicatorImg = (isOpen ? "../images/remove.gif" : "../images/add.gif"); struct dyString *header = dyStringNew(0); //keep the following line for future debugging need //printf("
printing %s section\n", section->name);fflush(stdout); dyStringPrintf(header, "", section->name); dyStringPrintf(header, "\"%s\"  ", geneCgi, cartSidUrlString(cart), closeVarName, otherState, section->name, indicatorImg, indicator); dyStringAppend(header, section->longLabel); webNewSection("%s",header->string); if (isOpen) { + long startTime = clock1000(); section->print(section, conn, geneId); + section->printTime = clock1000() - startTime; } else { printf("Press \"+\" in the title bar above to open this section."); } dyStringFree(&header); } } +void printTiming(struct section *sectionList) +/* Print timing for each section, if measureTiming is set */ +{ +if (!measureTiming) + return; +struct section *section; +int total = 0; +printf("

section, check time, print time, total
\n"); +for (section = sectionList; section != NULL; section = section->next) + { + char *closeVarName = sectionCloseVar(section->name); + boolean isOpen = !(cartUsualInt(cart, closeVarName, 0)); + int sectionTime = section->checkTime + section->printTime; + printf("%s, %d, %d, %d %s
\n", section->shortLabel, section->checkTime, section->printTime, + sectionTime, isOpen ? "" : "closed"); + total += sectionTime; + } +printf("total = %d\n", total); +printf("

"); +} + void webMain(struct sqlConnection *conn) /* Set up fancy web page with hotlinks bar and * sections. */ { struct section *sectionList = NULL; struct trackDb *tdb = hTrackDbForTrack(database, genomeSetting("knownGene")); printDescription(curGeneId, conn, tdb); sectionList = loadSectionList(conn); printIndex(sectionList); printUpdateTime(database, tdb, NULL); printSections(sectionList, conn, curGeneId); +printTiming(sectionList); } static char *findGeneId(struct sqlConnection *conn, char *name) /* Given some sort of gene name, see if it is in our primary gene table, and if not * look it up in alias table if we have one. */ { /* Just check if it's in the main gene table, and if so return input name. */ char *mainTable = genomeSetting("knownGene"); char query[256]; sqlSafef(query, sizeof(query), "select count(*) from %s where name = '%s'", mainTable, name); if (sqlQuickNum(conn, query) > 0) return name; else { /* check OMIM gene symbol table first */ @@ -685,30 +714,31 @@ if (cartVarExists(cart, hggDoGetMrnaSeq)) doGetMrnaSeq(conn, curGeneId, curGeneName); else if (cartVarExists(cart, hggDoWikiTrack)) doWikiTrack(conn); else if (cartVarExists(cart, hggDoGetProteinSeq)) doGetProteinSeq(conn, curGeneId, curGeneName); else if (cartVarExists(cart, hggDoRnaFoldDisplay)) doRnaFoldDisplay(conn, curGeneId, curGeneName); else if (cartVarExists(cart, hggDoOtherProteinSeq)) doOtherProteinSeq(conn, curGeneName); else if (cartVarExists(cart, hggDoOtherProteinAli)) doOtherProteinAli(conn, curGeneId, curGeneName); else { /* Default case - start fancy web page. */ + measureTiming = isNotEmpty(cartOptionalString(cart, "measureTiming")); cartWebStart(cart, database, "%s Gene %s (%s) Description and Page Index", genome, curGeneName, curAlignId); webMain(conn); cartWebEnd(); } hFreeConn(&spConn); hFreeConn(&conn); } cartRemovePrefix(cart, hggDoPrefix); } char *excludeVars[] = {"Submit", "submit", "ajax", hggAjaxSection, NULL}; int main(int argc, char *argv[]) /* Process command line. */