Index: src/stat.c ================================================================== --- src/stat.c +++ src/stat.c @@ -19,10 +19,29 @@ ** */ #include #include "config.h" #include "stat.h" + +/* +** For a sufficiently large integer, provide an alternative +** representation as MB or GB or TB. +*/ +static 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)", + (double)v/1000000.0, v); + }else if( v<1000000000000 ){ + sqlite3_snprintf(nOut, zOut, "%lld bytes (%.1fGB)", + (double)v/1000000000.0, v); + }else{ + sqlite3_snprintf(nOut, zOut, "%lld bytes (%.1fTB)", + (double)v/1000000000000.0, v); + } +} /* ** WEBPAGE: stat ** ** Show statistics and global information about the repository. @@ -40,12 +59,12 @@ brief = P("brief")!=0; style_header("Repository Statistics"); @ @ if( !brief ){ @ @
Repository Size: fsize = file_size(g.zRepositoryName); - sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", fsize); - @ %s(zBuf) bytes + bigSizeName(sizeof(zBuf), zBuf, fsize); + @ %s(zBuf) @
Number Of Artifacts: n = db_int(0, "SELECT count(*) FROM blob"); m = db_int(0, "SELECT count(*) FROM delta"); @@ -60,12 +79,12 @@ db_step(&q); t = db_column_int64(&q, 0); szAvg = db_column_int(&q, 1); szMax = db_column_int(&q, 2); db_finalize(&q); - sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", t); - @ %d(szAvg) bytes average, %d(szMax) bytes max, %s(zBuf) bytes total + bigSizeName(sizeof(zBuf), zBuf, t); + @ %d(szAvg) bytes average, %d(szMax) bytes max, %s(zBuf) total @
Compression Ratio: if( t/fsize < 5 ){ b = 10; fsize /= 10;