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, " ",
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("