Browse Source

ckdb/php - add age to block stats table

master
kanoi 9 years ago
parent
commit
e7c5d1ec82
  1. 48
      pool/base.php
  2. 3
      pool/page_blocks.php
  3. 2
      src/ckdb.h
  4. 7
      src/ckdb_cmd.c

48
pool/base.php

@ -28,6 +28,54 @@ function dq($str)
return str_replace('"', "\\\"", $str); return str_replace('"', "\\\"", $str);
} }
# #
function daysago($val)
{
if ($val < -13)
return '';
if ($val < 60)
$des = $val.'s';
else
{
$val = round($val/6)/10;
if ($val < 60)
$des = $val.'min';
else
{
$val = round($val/6)/10;
if ($val < 24)
{
$des = $val.'hr';
if ($val != 1)
$des .= 's';
}
else
{
$val = round($val/2.4)/10;
if ($val < 100)
{
$des = $val.'day';
if ($val != 1)
$des .= 's';
}
else
{
$val = round($val/0.7)/10;
if ($val < 10000)
{
$des = $val.'wk';
if ($val != 1)
$des .= 's';
}
else
$des = '';
}
}
}
}
return $des;
}
#
function howlongago($sec) function howlongago($sec)
{ {
if ($sec < 60) if ($sec < 60)

3
pool/page_blocks.php

@ -93,6 +93,7 @@ function doblocks($data, $user)
$pg .= "<table callpadding=0 cellspacing=0 border=0>\n"; $pg .= "<table callpadding=0 cellspacing=0 border=0>\n";
$pg .= "<tr class=title>"; $pg .= "<tr class=title>";
$pg .= "<td class=dl>Description</td>"; $pg .= "<td class=dl>Description</td>";
$pg .= "<td class=dr>Age</td>";
$pg .= "<td class=dr>Diff%</td>"; $pg .= "<td class=dr>Diff%</td>";
$pg .= "<td class=dr>Mean%</td>"; $pg .= "<td class=dr>Mean%</td>";
$pg .= "<td class=dr>CDF[Erl]</td>"; $pg .= "<td class=dr>CDF[Erl]</td>";
@ -108,6 +109,7 @@ function doblocks($data, $user)
$row = 'odd'; $row = 'odd';
$desc = $ans['s_desc:'.$i]; $desc = $ans['s_desc:'.$i];
$age = daysago($ans['STAMP'] - $ans['s_createdate:'.$i]);
$diff = number_format(100 * $ans['s_diffratio:'.$i], 2); $diff = number_format(100 * $ans['s_diffratio:'.$i], 2);
$mean = number_format(100 * $ans['s_diffmean:'.$i], 2); $mean = number_format(100 * $ans['s_diffmean:'.$i], 2);
@ -120,6 +122,7 @@ function doblocks($data, $user)
$pg .= "<tr class=$row>"; $pg .= "<tr class=$row>";
$pg .= "<td class=dl>$desc Blocks</td>"; $pg .= "<td class=dl>$desc Blocks</td>";
$pg .= "<td class=dl>$age</td>";
$pg .= "<td class=dr>$diff%</td>"; $pg .= "<td class=dr>$diff%</td>";
$pg .= "<td class=dr>$mean%</td>"; $pg .= "<td class=dr>$mean%</td>";
$pg .= "<td class=dr$bg>$cdferldsp</td>"; $pg .= "<td class=dr$bg>$cdferldsp</td>";

2
src/ckdb.h

@ -55,7 +55,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "1.0.2" #define DB_VERSION "1.0.2"
#define CKDB_VERSION DB_VERSION"-1.226" #define CKDB_VERSION DB_VERSION"-1.227"
#define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__ #define WHERE_FFL_HERE __FILE__, __func__, __LINE__

7
src/ckdb_cmd.c

@ -1303,12 +1303,16 @@ redo:
snprintf(tmp, sizeof(tmp), snprintf(tmp, sizeof(tmp),
"s_seq:%d=%d%c" "s_seq:%d=%d%c"
"s_desc:%d=%s%c" "s_desc:%d=%s%c"
"s_height:%d=%d%c"
"s_"CDTRF":%d=%ld%c"
"s_diffratio:%d=%.8f%c" "s_diffratio:%d=%.8f%c"
"s_diffmean:%d=%.8f%c" "s_diffmean:%d=%.8f%c"
"s_cdferl:%d=%.8f%c" "s_cdferl:%d=%.8f%c"
"s_luck:%d=%.8f%c", "s_luck:%d=%.8f%c",
srows, seq, FLDSEP, srows, seq, FLDSEP,
srows, desc, FLDSEP, srows, desc, FLDSEP,
srows, (int)(blocks->height), FLDSEP,
srows, blocks->createdate.tv_sec, FLDSEP,
srows, blocks->diffratio, FLDSEP, srows, blocks->diffratio, FLDSEP,
srows, blocks->diffmean, FLDSEP, srows, blocks->diffmean, FLDSEP,
srows, blocks->cdferl, FLDSEP, srows, blocks->cdferl, FLDSEP,
@ -1340,7 +1344,8 @@ redo:
snprintf(tmp, sizeof(tmp), snprintf(tmp, sizeof(tmp),
"s_rows=%d%cs_flds=%s%c", "s_rows=%d%cs_flds=%s%c",
srows, FLDSEP, srows, FLDSEP,
"s_seq,s_desc,s_diffratio,s_diffmean,s_cdferl,s_luck", "s_seq,s_desc,s_height,s_"CDTRF",s_diffratio,s_diffmean,"
"s_cdferl,s_luck",
FLDSEP); FLDSEP);
APPEND_REALLOC(buf, off, len, tmp); APPEND_REALLOC(buf, off, len, tmp);

Loading…
Cancel
Save