Add more profiling instrumentation

This commit is contained in:
Jeremy Lakeman 2012-07-03 15:12:42 +09:30
parent 78a8aaca16
commit 495de9e0ec
5 changed files with 30 additions and 15 deletions

View File

@ -211,6 +211,10 @@ int parseCommandLine(int argc, const char *const *args)
int i;
int ambiguous=0;
int cli_call=-1;
fd_clearstats();
IN();
for(i=0;command_line_options[i].function;i++)
{
int j;
@ -277,6 +281,10 @@ int parseCommandLine(int argc, const char *const *args)
int result=command_line_options[cli_call].function(argc, args, &command_line_options[cli_call]);
/* clean up after ourselves */
overlay_mdp_client_done();
OUT();
//TODO debug flag for method profiling
if (1)
fd_showstats();
return result;
}

View File

@ -739,7 +739,8 @@ int keyring_decrypt_pkr(keyring_file *k,keyring_context *c,
We might find more than one. */
int keyring_enter_pin(keyring_file *k, const char *pin)
{
if (!k) return -1;
IN();
if (!k) RETURN(-1);
if (!pin) pin="";
int slot;
@ -777,7 +778,7 @@ int keyring_enter_pin(keyring_file *k, const char *pin)
}
/* Tell the caller how many identities we found */
return identitiesFound;
RETURN(identitiesFound);
}
@ -1385,15 +1386,16 @@ int keyring_enter_pins(keyring_file *k, const char *pinlist)
keyring_file *keyring_open_with_pins(const char *pinlist)
{
keyring_file *k = NULL;
IN();
if (create_serval_instance_dir() == -1)
return NULL;
RETURN(NULL);
char keyringFile[1024];
if (!FORM_SERVAL_INSTANCE_PATH(keyringFile, "serval.keyring"))
return NULL;
RETURN(NULL);
if ((k = keyring_open(keyringFile)) == NULL)
return NULL;
RETURN(NULL);
keyring_enter_pins(k,pinlist);
return k;
RETURN(k);
}
/* If no identities, create an initial identity with a phone number.

View File

@ -1253,6 +1253,8 @@ int overlay_mdp_client_done()
int overlay_mdp_client_poll(long long timeout_ms)
{
fd_set r;
int ret;
IN();
FD_ZERO(&r);
FD_SET(mdp_client_socket,&r);
if (timeout_ms<0) timeout_ms=0;
@ -1262,10 +1264,11 @@ int overlay_mdp_client_poll(long long timeout_ms)
if (timeout_ms>=0) {
tv.tv_sec=timeout_ms/1000;
tv.tv_usec=(timeout_ms%1000)*1000;
return select(mdp_client_socket+1,&r,NULL,&r,&tv);
ret=select(mdp_client_socket+1,&r,NULL,&r,&tv);
}
else
return select(mdp_client_socket+1,&r,NULL,&r,NULL);
ret=select(mdp_client_socket+1,&r,NULL,&r,NULL);
RETURN(ret);
}
int overlay_mdp_recv(overlay_mdp_frame *mdp,int *ttl)

View File

@ -84,8 +84,9 @@ int rhizome_manifest_verify(rhizome_manifest *m)
int rhizome_read_manifest_file(rhizome_manifest *m, const char *filename, int bufferP)
{
if (bufferP>MAX_MANIFEST_BYTES) return WHY("Buffer too big");
if (!m) return WHY("Null manifest");
IN();
if (bufferP>MAX_MANIFEST_BYTES) RETURN(WHY("Buffer too big"));
if (!m) RETURN(WHY("Null manifest"));
if (bufferP) {
m->manifest_bytes=bufferP;
@ -93,7 +94,7 @@ int rhizome_read_manifest_file(rhizome_manifest *m, const char *filename, int bu
} else {
FILE *f = fopen(filename, "r");
if (f == NULL)
return WHYF("Could not open manifest file %s for reading.", filename);
RETURN(WHYF("Could not open manifest file %s for reading.", filename));
m->manifest_bytes = fread(m->manifestdata, 1, MAX_MANIFEST_BYTES, f);
int ret = 0;
if (m->manifest_bytes == -1)
@ -101,7 +102,7 @@ int rhizome_read_manifest_file(rhizome_manifest *m, const char *filename, int bu
if (fclose(f) == EOF)
ret = WHY_perror("fclose");
if (ret == -1)
return -1;
RETURN(-1);
}
m->manifest_all_bytes=m->manifest_bytes;
@ -175,7 +176,7 @@ int rhizome_read_manifest_file(rhizome_manifest *m, const char *filename, int bu
m->manifest_bytes=end_of_text;
return 0;
RETURN(0);
}
int rhizome_hash_file(rhizome_manifest *m,const char *filename,char *hash_out)

View File

@ -658,6 +658,7 @@ int rhizome_finish_sqlstatement(sqlite3_stmt *statement)
int rhizome_list_manifests(const char *service, const char *sender_sid, const char *recipient_sid, int limit, int offset)
{
IN();
strbuf b = strbuf_alloca(1024);
strbuf_sprintf(b, "SELECT id, manifest, version, inserttime FROM manifests ORDER BY inserttime DESC");
if (limit)
@ -665,7 +666,7 @@ int rhizome_list_manifests(const char *service, const char *sender_sid, const ch
if (offset)
strbuf_sprintf(b, " OFFSET %u", offset);
if (strbuf_overrun(b))
return WHYF("SQL command too long: ", strbuf_str(b));
RETURN(WHYF("SQL command too long: ", strbuf_str(b)));
sqlite3_stmt *statement;
const char *cmdtail;
int ret = 0;
@ -751,7 +752,7 @@ int rhizome_list_manifests(const char *service, const char *sender_sid, const ch
}
}
sqlite3_finalize(statement);
return ret;
RETURN(ret);
}
/* The following function just stores the file (or silently returns if it already exists).