Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add the "," qualifier to %d formats in printf() and use the capability for improve display of stats. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
2cdbdbb1c9b7ad2b7b7cf4d23844227d |
| User & Date: | drh 2017-12-11 16:53:08.616 |
Context
|
2017-12-11
| ||
| 16:56 | Fix documentation typo. check-in: ca1a1a750d user: drh tags: trunk | |
| 16:53 | Add the "," qualifier to %d formats in printf() and use the capability for improve display of stats. check-in: 2cdbdbb1c9 user: drh tags: trunk | |
| 16:10 | On the /artifact_stats page, relabel "unknown" artifacts as "unused". check-in: 71e777dd73 user: drh tags: trunk | |
Changes
Changes to src/printf.c.
| ︙ | ︙ | |||
273 274 275 276 277 278 279 280 281 282 283 284 285 286 | etByte flag_blanksign; /* True if " " flag is present */ etByte flag_alternateform; /* True if "#" flag is present */ etByte flag_altform2; /* True if "!" flag is present */ etByte flag_zeropad; /* True if field width constant starts with zero */ etByte flag_long; /* True if "l" flag is present */ etByte flag_longlong; /* True if the "ll" flag is present */ etByte done; /* Loop termination flag */ u64 longvalue; /* Value for integer types */ long double realvalue; /* Value for real types */ const et_info *infop; /* Pointer to the appropriate info structure */ char buf[etBUFSIZE]; /* Conversion buffer */ char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */ etByte errorflag = 0; /* True if an error is encountered */ etByte xtype; /* Conversion paradigm */ | > | 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | etByte flag_blanksign; /* True if " " flag is present */ etByte flag_alternateform; /* True if "#" flag is present */ etByte flag_altform2; /* True if "!" flag is present */ etByte flag_zeropad; /* True if field width constant starts with zero */ etByte flag_long; /* True if "l" flag is present */ etByte flag_longlong; /* True if the "ll" flag is present */ etByte done; /* Loop termination flag */ etByte cThousand; /* Thousands separator for %d and %u */ u64 longvalue; /* Value for integer types */ long double realvalue; /* Value for real types */ const et_info *infop; /* Pointer to the appropriate info structure */ char buf[etBUFSIZE]; /* Conversion buffer */ char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */ etByte errorflag = 0; /* True if an error is encountered */ etByte xtype; /* Conversion paradigm */ |
| ︙ | ︙ | |||
310 311 312 313 314 315 316 |
if( (c=(*++fmt))==0 ){
errorflag = 1;
blob_append(pBlob,"%",1);
count++;
break;
}
/* Find out what flags are present */
| | > | 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
if( (c=(*++fmt))==0 ){
errorflag = 1;
blob_append(pBlob,"%",1);
count++;
break;
}
/* Find out what flags are present */
flag_leftjustify = flag_plussign = flag_blanksign = cThousand =
flag_alternateform = flag_altform2 = flag_zeropad = 0;
done = 0;
do{
switch( c ){
case '-': flag_leftjustify = 1; break;
case '+': flag_plussign = 1; break;
case ' ': flag_blanksign = 1; break;
case '#': flag_alternateform = 1; break;
case '!': flag_altform2 = 1; break;
case '0': flag_zeropad = 1; break;
case ',': cThousand = ','; break;
default: done = 1; break;
}
}while( !done && (c=(*++fmt))!=0 );
/* Get the field width */
width = 0;
if( c=='*' ){
width = va_arg(ap,int);
|
| ︙ | ︙ | |||
452 453 454 455 456 457 458 |
base = infop->base;
do{ /* Convert to ascii */
*(--bufpt) = cset[longvalue%base];
longvalue = longvalue/base;
}while( longvalue>0 );
}
length = &buf[etBUFSIZE-1]-bufpt;
| | > > > > > > > > > > > > > > > | 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 |
base = infop->base;
do{ /* Convert to ascii */
*(--bufpt) = cset[longvalue%base];
longvalue = longvalue/base;
}while( longvalue>0 );
}
length = &buf[etBUFSIZE-1]-bufpt;
while( precision>length ){
*(--bufpt) = '0'; /* Zero pad */
length++;
}
if( cThousand ){
int nn = (length - 1)/3; /* Number of "," to insert */
int ix = (length - 1)%3 + 1;
bufpt -= nn;
for(idx=0; nn>0; idx++){
bufpt[idx] = bufpt[idx+nn];
ix--;
if( ix==0 ){
bufpt[++idx] = cThousand;
nn--;
ix = 3;
}
}
}
if( prefix ) *(--bufpt) = prefix; /* Add sign */
if( flag_alternateform && infop->prefix ){ /* Add "0" or "0x" */
const char *pre;
char x;
pre = &aPrefix[infop->prefix];
if( *bufpt!=pre[0] ){
|
| ︙ | ︙ |
Changes to src/stat.c.
| ︙ | ︙ | |||
25 26 27 28 29 30 31 |
/*
** For a sufficiently large integer, provide an alternative
** representation as MB or GB or TB.
*/
void bigSizeName(int nOut, char *zOut, sqlite3_int64 v){
if( v<100000 ){
| | | | | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
/*
** For a sufficiently large integer, provide an alternative
** representation as MB or GB or TB.
*/
void bigSizeName(int nOut, char *zOut, sqlite3_int64 v){
if( v<100000 ){
sqlite3_snprintf(nOut, zOut, "%,lld bytes", v);
}else if( v<1000000000 ){
sqlite3_snprintf(nOut, zOut, "%,lld bytes (%.1fMB)",
v, (double)v/1000000.0);
}else{
sqlite3_snprintf(nOut, zOut, "%,lld bytes (%.1fGB)",
v, (double)v/1000000000.0);
}
}
/*
** Return the approximate size as KB, MB, GB, or TB.
*/
void approxSizeName(int nOut, char *zOut, sqlite3_int64 v){
if( v<1000 ){
sqlite3_snprintf(nOut, zOut, "%,lld bytes", v);
}else if( v<1000000 ){
sqlite3_snprintf(nOut, zOut, "%.1fKB", (double)v/1000.0);
}else if( v<1000000000 ){
sqlite3_snprintf(nOut, zOut, "%.1fMB", (double)v/1000000.0);
}else{
sqlite3_snprintf(nOut, zOut, "%.1fGB", (double)v/1000000000.0);
}
|
| ︙ | ︙ | |||
83 84 85 86 87 88 89 |
if( sqlite3_compileoption_used("ENABLE_DBSTAT_VTAB") ){
style_submenu_element("Table Sizes", "repo-tabsize");
}
if( g.perm.Admin || g.perm.Setup || db_get_boolean("test_env_enable",0) ){
style_submenu_element("Environment", "test_env");
}
@ <table class="label-value">
| < | < | < | | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
if( sqlite3_compileoption_used("ENABLE_DBSTAT_VTAB") ){
style_submenu_element("Table Sizes", "repo-tabsize");
}
if( g.perm.Admin || g.perm.Setup || db_get_boolean("test_env_enable",0) ){
style_submenu_element("Environment", "test_env");
}
@ <table class="label-value">
fsize = file_size(g.zRepositoryName, ExtFILE);
@ <tr><th>Repository Size:</th><td>%,lld(fsize) bytes</td>
@ </td></tr>
if( !brief ){
@ <tr><th>Number Of Artifacts:</th><td>
n = db_int(0, "SELECT count(*) FROM blob");
m = db_int(0, "SELECT count(*) FROM delta");
@ %.d(n) (%,d(n-m) fulltext and %,d(m) deltas)
if( g.perm.Write ){
@ <a href='%R/artifact_stats'>Details</a>
}
@ </td></tr>
if( n>0 ){
int a, b;
Stmt q;
@ <tr><th>Uncompressed Artifact Size:</th><td>
db_prepare(&q, "SELECT total(size), avg(size), max(size)"
" FROM blob WHERE size>0 /*scan*/");
db_step(&q);
t = db_column_int64(&q, 0);
szAvg = db_column_int(&q, 1);
szMax = db_column_int(&q, 2);
db_finalize(&q);
@ %,d(szAvg) bytes average, %,d(szMax) bytes max, %,lld(t) total
@ </td></tr>
@ <tr><th>Compression Ratio:</th><td>
if( t/fsize < 5 ){
b = 10;
a = t/(fsize/10);
}else{
b = 1;
|
| ︙ | ︙ | |||
144 145 146 147 148 149 150 |
@ %s(zStored) compressed, %d(pct)%% of total repository space
@ </td></tr>
}
db_finalize(&q);
}
@ <tr><th>Number Of Check-ins:</th><td>
n = db_int(0, "SELECT count(*) FROM event WHERE type='ci' /*scan*/");
| | | | | | | 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
@ %s(zStored) compressed, %d(pct)%% of total repository space
@ </td></tr>
}
db_finalize(&q);
}
@ <tr><th>Number Of Check-ins:</th><td>
n = db_int(0, "SELECT count(*) FROM event WHERE type='ci' /*scan*/");
@ %,d(n)
@ </td></tr>
@ <tr><th>Number Of Files:</th><td>
n = db_int(0, "SELECT count(*) FROM filename /*scan*/");
@ %,d(n)
@ </td></tr>
@ <tr><th>Number Of Wiki Pages:</th><td>
n = db_int(0, "SELECT count(*) FROM tag /*scan*/"
" WHERE +tagname GLOB 'wiki-*'");
@ %,d(n)
@ </td></tr>
@ <tr><th>Number Of Tickets:</th><td>
n = db_int(0, "SELECT count(*) FROM tag /*scan*/"
" WHERE +tagname GLOB 'tkt-*'");
@ %,d(n)
@ </td></tr>
}
@ <tr><th>Duration Of Project:</th><td>
n = db_int(0, "SELECT julianday('now') - (SELECT min(mtime) FROM event)"
" + 0.99");
@ %,d(n) days or approximately %.2f(n/365.2425) years.
@ </td></tr>
p = db_get("project-code", 0);
if( p ){
@ <tr><th>Project ID:</th>
@ <td>%h(p) %h(db_get("project-name",""))</td></tr>
}
p = db_get("parent-project-code", 0);
|
| ︙ | ︙ | |||
194 195 196 197 198 199 200 |
}else{
@ <tr><th>Schema Version:</th><td>%h(g.zAuxSchema)</td></tr>
}
@ <tr><th>Repository Rebuilt:</th><td>
@ %h(db_get_mtime("rebuilt","%Y-%m-%d %H:%M:%S","Never"))
@ By Fossil %h(db_get("rebuilt","Unknown"))</td></tr>
@ <tr><th>Database Stats:</th><td>
| | | | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
}else{
@ <tr><th>Schema Version:</th><td>%h(g.zAuxSchema)</td></tr>
}
@ <tr><th>Repository Rebuilt:</th><td>
@ %h(db_get_mtime("rebuilt","%Y-%m-%d %H:%M:%S","Never"))
@ By Fossil %h(db_get("rebuilt","Unknown"))</td></tr>
@ <tr><th>Database Stats:</th><td>
@ %,d(db_int(0, "PRAGMA repository.page_count")) pages,
@ %d(db_int(0, "PRAGMA repository.page_size")) bytes/page,
@ %,d(db_int(0, "PRAGMA repository.freelist_count")) free pages,
@ %s(db_text(0, "PRAGMA repository.encoding")),
@ %s(db_text(0, "PRAGMA repository.journal_mode")) mode
@ </td></tr>
@ </table>
style_footer();
}
|
| ︙ | ︙ | |||
243 244 245 246 247 248 249 |
if( (z = db_get("project-name",0))!=0
|| (z = db_get("short-project-name",0))!=0
){
fossil_print("%*s%s\n", colWidth, "project-name:", z);
}
fsize = file_size(g.zRepositoryName, ExtFILE);
| < | | < | | | | | | | | | | | | 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
if( (z = db_get("project-name",0))!=0
|| (z = db_get("short-project-name",0))!=0
){
fossil_print("%*s%s\n", colWidth, "project-name:", z);
}
fsize = file_size(g.zRepositoryName, ExtFILE);
fossil_print( "%*s%,lld bytes\n", colWidth, "repository-size:", fsize);
if( !brief ){
n = db_int(0, "SELECT count(*) FROM blob");
m = db_int(0, "SELECT count(*) FROM delta");
fossil_print("%*s%,d (stored as %,d full text and %,d deltas)\n",
colWidth, "artifact-count:",
n, n-m, m);
if( n>0 ){
int a, b;
Stmt q;
db_prepare(&q, "SELECT total(size), avg(size), max(size)"
" FROM blob WHERE size>0");
db_step(&q);
t = db_column_int64(&q, 0);
szAvg = db_column_int(&q, 1);
szMax = db_column_int(&q, 2);
db_finalize(&q);
fossil_print( "%*s%,d average, "
"%,d max, %,lld total\n",
colWidth, "artifact-sizes:",
szAvg, szMax, t);
if( t/fsize < 5 ){
b = 10;
fsize /= 10;
}else{
b = 1;
}
a = t/fsize;
fossil_print("%*s%d:%d\n", colWidth, "compression-ratio:", a, b);
}
n = db_int(0, "SELECT COUNT(*) FROM event e WHERE e.type='ci'");
fossil_print("%*s%,d\n", colWidth, "check-ins:", n);
n = db_int(0, "SELECT count(*) FROM filename /*scan*/");
fossil_print("%*s%,d across all branches\n", colWidth, "files:", n);
n = db_int(0, "SELECT count(*) FROM tag /*scan*/"
" WHERE tagname GLOB 'wiki-*'");
m = db_int(0, "SELECT COUNT(*) FROM event WHERE type='w'");
fossil_print("%*s%,d (%,d changes)\n", colWidth, "wiki-pages:", n, m);
n = db_int(0, "SELECT count(*) FROM tag /*scan*/"
" WHERE tagname GLOB 'tkt-*'");
m = db_int(0, "SELECT COUNT(*) FROM event WHERE type='t'");
fossil_print("%*s%,d (%,d changes)\n", colWidth, "tickets:", n, m);
n = db_int(0, "SELECT COUNT(*) FROM event WHERE type='e'");
fossil_print("%*s%,d\n", colWidth, "events:", n);
n = db_int(0, "SELECT COUNT(*) FROM event WHERE type='g'");
fossil_print("%*s%,d\n", colWidth, "tag-changes:", n);
z = db_text(0, "SELECT datetime(mtime) || ' - about ' ||"
" CAST(julianday('now') - mtime AS INTEGER)"
" || ' days ago' FROM event "
" ORDER BY mtime DESC LIMIT 1");
fossil_print("%*s%s\n", colWidth, "latest-change:", z);
}
n = db_int(0, "SELECT julianday('now') - (SELECT min(mtime) FROM event)"
" + 0.99");
fossil_print("%*s%,d days or approximately %.2f years.\n",
colWidth, "project-age:", n, n/365.2425);
p = db_get("project-code", 0);
if( p ){
fossil_print("%*s%s\n", colWidth, "project-id:", p);
}
#if 0
/* Server-id is not useful information any more */
fossil_print("%*s%s\n", colWidth, "server-id:", db_get("server-code", 0));
#endif
fossil_print("%*s%s\n", colWidth, "schema-version:", g.zAuxSchema);
if( !omitVers ){
fossil_print("%*s%s %s [%s] (%s)\n",
colWidth, "fossil-version:",
MANIFEST_DATE, MANIFEST_VERSION, RELEASE_VERSION,
COMPILER_NAME);
fossil_print("%*s%.19s [%.10s] (%s)\n",
colWidth, "sqlite-version:",
sqlite3_sourceid(), &sqlite3_sourceid()[20],
sqlite3_libversion());
}
fossil_print("%*s%,d pages, %d bytes/pg, %,d free pages, "
"%s, %s mode\n",
colWidth, "database-stats:",
db_int(0, "PRAGMA repository.page_count"),
db_int(0, "PRAGMA repository.page_size"),
db_int(0, "PRAGMA repository.freelist_count"),
db_text(0, "PRAGMA repository.encoding"),
db_text(0, "PRAGMA repository.journal_mode"));
|
| ︙ | ︙ | |||
642 643 644 645 646 647 648 |
/*
** Output text "the largest N artifacts". Make this text a hyperlink
** to bigbloblist if N is not too big.
*/
static void largest_n_artifacts(int N){
if( N>250 ){
| | | 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 |
/*
** Output text "the largest N artifacts". Make this text a hyperlink
** to bigbloblist if N is not too big.
*/
static void largest_n_artifacts(int N){
if( N>250 ){
@ (the largest %,d(N) artifacts)
}else{
@ (the <a href='%R/bigbloblist?n=%d(N)'>largest %d(N) artifacts</a>)
}
}
/*
** WEBPAGE: artifact_stats
|
| ︙ | ︙ | |||
729 730 731 732 733 734 735 |
if( n==(nTotal+1)/2 ){ sz50pct = r; medCmpr = db_column_int(&q,0); }
n++;
}
db_finalize(&q);
@ <h1>Overall Artifact Size Statistics:</h1>
@ <table class="label-value">
| | | | < < < < < < < < < | > > > > > < | < < | < > > | < | > | 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 |
if( n==(nTotal+1)/2 ){ sz50pct = r; medCmpr = db_column_int(&q,0); }
n++;
}
db_finalize(&q);
@ <h1>Overall Artifact Size Statistics:</h1>
@ <table class="label-value">
@ <tr><th>Number of artifacts:</th><td>%,d(nTotal)</td></tr>
@ <tr><th>Number of deltas:</th>\
@ <td>%,d(nDelta) (%d(nDelta*100/nTotal)%%)</td></tr>
@ <tr><th>Number of full-text:</th><td>%,d(nFull) \
@ (%d(nFull*100/nTotal)%%)</td></tr>
medExp = db_int(0, "SELECT szExp FROM artstat ORDER BY szExp"
" LIMIT 1 OFFSET %d", nTotal/2);
@ <tr><th>Uncompressed artifact sizes:</th>\
@ <td>largest: %,d(mxExp), average: %,d((int)avgExp), median: %,d(medExp)</td>
@ <tr><th>Compressed artifact sizes:</th>\
@ <td>largest: %,d(mxCmpr), average: %,d((int)avgCmpr), \
@ median: %,d(medCmpr)</td>
db_prepare(&q,
"SELECT avg(szCmpr), max(szCmpr) FROM artstat WHERE isDelta"
);
if( db_step(&q)==SQLITE_ROW ){
int mxDelta = db_column_int(&q,1);
double avgDelta = db_column_double(&q,0);
med = db_int(0, "SELECT szCmpr FROM artstat WHERE isDelta ORDER BY szCmpr"
" LIMIT 1 OFFSET %d", nDelta/2);
@ <tr><th>Delta artifact sizes:</th>\
@ <td>largest: %,d(mxDelta), average: %,d((int)avgDelta), \
@ median: %,d(med)</td>
}
db_finalize(&q);
r = db_double(0.0, "SELECT avg(szCmpr) FROM artstat WHERE NOT isDelta;");
med = db_int(0, "SELECT szCmpr FROM artstat WHERE NOT isDelta ORDER BY szCmpr"
" LIMIT 1 OFFSET %d", nFull/2);
@ <tr><th>Full-text artifact sizes:</th>
@ <td>largest: %,d(mxCmpr), average: %,d((int)r), median: %,d(med)</td>
@ </table>
@ <h1>Artifact size distribution facts:</h1>
@ <ol>
@ <li><p>The largest %.2f(n50pct*100.0/nTotal)%% of artifacts
largest_n_artifacts(n50pct);
@ use 50%% of the total artifact space.
|
| ︙ | ︙ | |||
815 816 817 818 819 820 821 |
int nTotal = db_column_int(&q, 1);
int nDelta = db_column_int(&q, 2);
int nFull = nTotal - nDelta;
sqlite3_int64 szCmpr = db_column_int64(&q, 3);
sqlite3_int64 szExp = db_column_int64(&q, 4);
char *z;
@ <tr><td>%h(zType)</td>
| < < | < < < | < < < | < < < | < < < | < | 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 |
int nTotal = db_column_int(&q, 1);
int nDelta = db_column_int(&q, 2);
int nFull = nTotal - nDelta;
sqlite3_int64 szCmpr = db_column_int64(&q, 3);
sqlite3_int64 szExp = db_column_int64(&q, 4);
char *z;
@ <tr><td>%h(zType)</td>
@ <td data-sortkey='%08x(nTotal)' align='right'>%,d(nTotal)</td>
@ <td data-sortkey='%08x(nFull)' align='right'>%,d(nFull)</td>
@ <td data-sortkey='%08x(nDelta)' align='right'>%,d(nDelta)</td>
@ <td data-sortkey='%016x(szCmpr)' align='right'>%,lld(szCmpr)</td>
@ <td data-sortkey='%016x(szExp)' align='right'>%,lld(szExp)</td>
}
@ </tbody></table>
db_finalize(&q);
if( db_exists("SELECT 1 FROM artstat WHERE atype='unused'") ){
@ <h1>Unused Artifacts:</h1>
db_prepare(&q,
|
| ︙ | ︙ |