Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: mizerydearia on July 16, 2010, 05:24:25 AM



Title: Some Statistics
Post by: mizerydearia on July 16, 2010, 05:24:25 AM
http://nullvoid.org/bitcoin/statistix.php
http://nullvoid.org/bitcoin/statistix.php?showallblocks (if you want to see timestamps for all 69,000+ blocks until now) (2.5Mb+ output)
http://jsonrpcphp.org/?page=download&lang=en

statistix.php
Code:
<?
header("Content-type: text/html");
require_once 'jsonRPCClient.php';
$data=new jsonRPCClient('http://127.0.0.1:8332');
$blockcount = $data->getblockcount();
$now = date("U");

$blockfile = "blockdata";
$data = file($blockfile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); array_pop($data);
foreach ($data as $line) {
$blocks = strtok($line, " ");
$date = strtok(" ");
$avghash = strtok(" ");
}
?><html>
 <head>
  <meta http-equiv="refresh" content="100000">
 </head>
 <body><pre>
<?
$data = array_reverse($data);
echo " /-             Statistix             -\\\n";
echo "|            <a href=\"http://bitcointalk.org/index.php?topic=402.msg3395#msg3395\">PHP Source Code</a>            |\n";
echo "|---------------------------------------|\n";
echo "|   Last block discovered in duration   |\n";
echo "|       and when it was discovered      |\n";
echo "|---------------------------------------|\n";
echo "|          Now  $now              |\n";
$lastdate = $now - $date; $lastdate .= ($lastdate == 1) ? " sec" : " secs"; $lastdate .= str_repeat(" ", 10 - strlen($lastdate));
$lastblock = trim($blocks); $lastblock .= str_repeat(" ", 12 - strlen($lastblock));
echo "|   Last Block  $lastdate:$lastblock |\n";
$block = array();
foreach ($data as $line) {
$blocks = strtok($line, " ");
$date = strtok(" ");
$avghash = strtok(" ");
$block[$blocks] = $date;
if (($now - 60) <= $date) { $min01date = $date; $min01blocks = $blocks; }
if (($now - 120) <= $date) { $min02date = $date; $min02blocks = $blocks; }
if (($now - 180) <= $date) { $min03date = $date; $min03blocks = $blocks; }
if (($now - 240) <= $date) { $min04date = $date; $min04blocks = $blocks; }
if (($now - 300) <= $date) { $min05date = $date; $min05blocks = $blocks; }
if (($now - 600) <= $date) { $min10date = $date; $min10blocks = $blocks; }
if (($now - 1200) <= $date) { $min20date = $date; $min20blocks = $blocks; }
if (($now - 1800) <= $date) { $min30date = $date; $min30blocks = $blocks; }
if (($now - 2400) <= $date) { $min40date = $date; $min40blocks = $blocks; }
if (($now - 3000) <= $date) { $min50date = $date; $min50blocks = $blocks; }
if (($now - 3600) <= $date) { $hr01date = $date; $hr01blocks = $blocks; }
if (($now - 7200) <= $date) { $hr02date = $date; $hr02blocks = $blocks; }
if (($now - 10800) <= $date) { $hr03date = $date; $hr03blocks = $blocks; }
if (($now - 14400) <= $date) { $hr04date = $date; $hr04blocks = $blocks; }
if (($now - 18000) <= $date) { $hr05date = $date; $hr05blocks = $blocks; }
if (($now - 21600) <= $date) { $hr06date = $date; $hr06blocks = $blocks; }
if (($now - 51200) <= $date) { $hr12date = $date; $hr12blocks = $blocks; }
if (($now - 102400) <= $date) { $day1date = $date; $day1blocks = $blocks; }
if (($now - 204800) <= $date) { $day2date = $date; $day2blocks = $blocks; }
if (($now - 307200) <= $date) { $day3date = $date; $day3blocks = $blocks; }
if (($now - 409600) <= $date) { $day4date = $date; $day4blocks = $blocks; }
if (($now - 512000) <= $date) { $day5date = $date; $day5blocks = $blocks; }
if (($now - 614400) <= $date) { $day6date = $date; $day6blocks = $blocks; }
if (($now - 716800) <= $date) { $wk01date = $date; $wk01blocks = $blocks; }
if (($now - 1433600) <= $date) { $wk02date = $date; $wk02blocks = $blocks; }
if (($now - 2150400) <= $date) { $wk03date = $date; $wk03blocks = $blocks; }
if (($now - 2867200) <= $date) { $wk04date = $date; $wk04blocks = $blocks; }
if (($now - 5734400) <= $date) { $wk08date = $date; $wk08blocks = $blocks; }
if (($now - 11468800) <= $date) { $wk16date = $date; $wk16blocks = $blocks; }
if (($now - 22937600) <= $date) { $wk32date = $date; $wk32blocks = $blocks; }
if (($now - 37376000) <= $date) { $yr1date = $date; $yr1blocks = $blocks; }
}

if ($min01blocks == "") $min01 = ""; else $min01 = "$min01date:$min01blocks";
if ($min02blocks == "") $min02 = ""; else $min02 = "$min02date:$min02blocks";
if ($min03blocks == "") $min03 = ""; else $min03 = "$min03date:$min03blocks";
if ($min04blocks == "") $min04 = ""; else $min04 = "$min04date:$min04blocks";
if ($min05blocks == "") $min05 = ""; else $min05 = "$min05date:$min05blocks";
if ($min10blocks == "") $min10 = ""; else $min10 = "$min10date:$min10blocks";
if ($min20blocks == "") $min20 = ""; else $min20 = "$min20date:$min20blocks";
if ($min30blocks == "") $min30 = ""; else $min30 = "$min30date:$min30blocks";
if ($min40blocks == "") $min40 = ""; else $min40 = "$min40date:$min40blocks";
if ($min50blocks == "") $min50 = ""; else $min50 = "$min50date:$min50blocks";
if ($hr01blocks == "") $hr01 = ""; else $hr01 = "$hr01date:$hr01blocks";
if ($hr02blocks == "") $hr02 = ""; else $hr02 = "$hr02date:$hr02blocks";
if ($hr03blocks == "") $hr03 = ""; else $hr03 = "$hr03date:$hr03blocks";
if ($hr04blocks == "") $hr04 = ""; else $hr04 = "$hr04date:$hr04blocks";
if ($hr05blocks == "") $hr05 = ""; else $hr05 = "$hr05date:$hr05blocks";
if ($hr06blocks == "") $hr06 = ""; else $hr06 = "$hr06date:$hr06blocks";
if ($hr12blocks == "") $hr12 = ""; else $hr12 = "$hr12date:$hr12blocks";
if ($day1blocks == "") $day1 = ""; else $day1 = "$day1date:$day1blocks";
if ($day2blocks == "") $day2 = ""; else $day2 = "$day2date:$day2blocks";
if ($day3blocks == "") $day3 = ""; else $day3 = "$day3date:$day3blocks";
if ($day4blocks == "") $day4 = ""; else $day4 = "$day4date:$day4blocks";
if ($day5blocks == "") $day5 = ""; else $day5 = "$day5date:$day5blocks";
if ($day6blocks == "") $day6 = ""; else $day6 = "$day6date:$day6blocks";
if ($wk01blocks == "") $wk01 = ""; else $wk01 = "$wk01date:$wk01blocks";
if ($wk02blocks == "") $wk02 = ""; else $wk02 = "$wk02date:$wk02blocks";
if ($wk03blocks == "") $wk03 = ""; else $wk03 = "$wk03date:$wk03blocks";
if ($wk04blocks == "") $wk04 = ""; else $wk04 = "$wk04date:$wk04blocks";
if ($wk08blocks == "") $wk08 = ""; else $wk08 = "$wk08date:$wk08blocks";
if ($wk16blocks == "") $wk16 = ""; else $wk16 = "$wk16date:$wk16blocks";
if ($wk32blocks == "") $wk32 = ""; else $wk32 = "$wk32date:$wk32blocks";
if ($yr1blocks == "") $yr1 = ""; else $yr1 = "$yr1date:$yr1blocks";

echo "|    1min  ago  ".$min01.str_repeat(" ", 24 - strlen($min01))."|\n";
echo "|    2min  ago  ".$min02.str_repeat(" ", 24 - strlen($min02))."|\n";
echo "|    3min  ago  ".$min03.str_repeat(" ", 24 - strlen($min03))."|\n";
echo "|    4min  ago  ".$min04.str_repeat(" ", 24 - strlen($min04))."|\n";
echo "|    5min  ago  ".$min05.str_repeat(" ", 24 - strlen($min05))."|\n";
echo "|   10min  ago  ".$min10.str_repeat(" ", 24 - strlen($min10))."|\n";
echo "|   20min  ago  ".$min20.str_repeat(" ", 24 - strlen($min20))."|\n";
echo "|   30min  ago  ".$min30.str_repeat(" ", 24 - strlen($min30))."|\n";
echo "|   40min  ago  ".$min40.str_repeat(" ", 24 - strlen($min40))."|\n";
echo "|   50min  ago  ".$min50.str_repeat(" ", 24 - strlen($min50))."|\n";
echo "|    1hr   ago  ".$hr01.str_repeat(" ", 24 - strlen($hr01))."|\n";
echo "|    2hrs  ago  ".$hr02.str_repeat(" ", 24 - strlen($hr02))."|\n";
echo "|    3hrs  ago  ".$hr03.str_repeat(" ", 24 - strlen($hr03))."|\n";
echo "|    4hrs  ago  ".$hr04.str_repeat(" ", 24 - strlen($hr04))."|\n";
echo "|    5hrs  ago  ".$hr05.str_repeat(" ", 24 - strlen($hr05))."|\n";
echo "|    6hrs  ago  ".$hr06.str_repeat(" ", 24 - strlen($hr06))."|\n";
echo "|   12hrs  ago  ".$hr12.str_repeat(" ", 24 - strlen($hr12))."|\n";
echo "|    1day  ago  ".$day1.str_repeat(" ", 24 - strlen($day1))."|\n";
echo "|    2days ago  ".$day2.str_repeat(" ", 24 - strlen($day2))."|\n";
echo "|    3days ago  ".$day3.str_repeat(" ", 24 - strlen($day3))."|\n";
echo "|    4days ago  ".$day4.str_repeat(" ", 24 - strlen($day4))."|\n";
echo "|    5days ago  ".$day5.str_repeat(" ", 24 - strlen($day5))."|\n";
echo "|    6days ago  ".$day6.str_repeat(" ", 24 - strlen($day6))."|\n";
echo "|    1wk   ago  ".$wk01.str_repeat(" ", 24 - strlen($wk01))."|\n";
echo "|    2wks  ago  ".$wk02.str_repeat(" ", 24 - strlen($wk02))."|\n";
echo "|    3wks  ago  ".$wk03.str_repeat(" ", 24 - strlen($wk03))."|\n";
echo "|    4wks  ago  ".$wk04.str_repeat(" ", 24 - strlen($wk04))."|\n";
echo "|    8wks  ago  ".$wk08.str_repeat(" ", 24 - strlen($wk08))."|\n";
echo "|   16wks  ago  ".$wk16.str_repeat(" ", 24 - strlen($wk16))."|\n";
echo "|   32wks  ago  ".$wk32.str_repeat(" ", 24 - strlen($wk32))."|\n";
echo "|    1yr   ago  ".$yr1.str_repeat(" ", 24 - strlen($yr1))."|\n";
echo "|---------------------------------------/\n";
if (isset($min01blocks)) $min01c = ($blockcount - $min01blocks); else $min01c = 0; echo "| ".fill(number_format($min01c, 0, ".", ","),9)." blocks in last minute\n";
if (isset($min02blocks)) $min02c = ($blockcount - $min02blocks); else $min02c = 0; echo "| ".fill(number_format($min02c, 0, ".", ","),9)." blocks in last 2 mins\n";
if (isset($min03blocks)) $min03c = ($blockcount - $min03blocks); else $min03c = 0; echo "| ".fill(number_format($min03c, 0, ".", ","),9)." blocks in last 3 mins\n";
if (isset($min04blocks)) $min04c = ($blockcount - $min04blocks); else $min04c = 0; echo "| ".fill(number_format($min04c, 0, ".", ","),9)." blocks in last 4 mins\n";
if (isset($min05blocks)) $min05c = ($blockcount - $min05blocks); else $min05c = 0; echo "| ".fill(number_format($min05c, 0, ".", ","),9)." blocks in last 5 mins\n";
if (isset($min10blocks)) $min10c = ($blockcount - $min10blocks); else $min10c = 0; echo "| ".fill(number_format($min10c, 0, ".", ","),9)." blocks in last 10 mins\n";
if (isset($min20blocks)) $min20c = ($blockcount - $min20blocks); else $min20c = 0; echo "| ".fill(number_format($min20c, 0, ".", ","),9)." blocks in last 20 mins\n";
if (isset($min30blocks)) $min30c = ($blockcount - $min30blocks); else $min30c = 0; echo "| ".fill(number_format($min30c, 0, ".", ","),9)." blocks in last 30 mins\n";
if (isset($min40blocks)) $min40c = ($blockcount - $min40blocks); else $min40c = 0; echo "| ".fill(number_format($min40c, 0, ".", ","),9)." blocks in last 40 mins\n";
if (isset($min50blocks)) $min50c = ($blockcount - $min50blocks); else $min50c = 0; echo "| ".fill(number_format($min50c, 0, ".", ","),9)." blocks in last 50 mins\n";
if (isset($hr01blocks)) $hr01c = ($blockcount - $hr01blocks); else $hr01c = 0; echo "| ".fill(number_format($hr01c, 0, ".", ","),9)." blocks in last hour\n";
if (isset($hr02blocks)) $hr02c = ($blockcount - $hr02blocks); else $hr02c = 0; echo "| ".fill(number_format($hr02c, 0, ".", ","),9)." blocks in last 2 hrs";echo "    blocks/hr avg: ".($hr02c / 2)."\n";
if (isset($hr03blocks)) $hr03c = ($blockcount - $hr03blocks); else $hr03c = 0; echo "| ".fill(number_format($hr03c, 0, ".", ","),9)." blocks in last 3 hrs";echo "    blocks/hr avg: ".($hr03c / 3)."\n";
if (isset($hr04blocks)) $hr04c = ($blockcount - $hr04blocks); else $hr04c = 0; echo "| ".fill(number_format($hr04c, 0, ".", ","),9)." blocks in last 4 hrs";echo "    blocks/hr avg: ".($hr04c / 4)."\n";
if (isset($hr05blocks)) $hr05c = ($blockcount - $hr05blocks); else $hr05c = 0; echo "| ".fill(number_format($hr05c, 0, ".", ","),9)." blocks in last 5 hrs";echo "    blocks/hr avg: ".($hr05c / 5)."\n";
if (isset($hr06blocks)) $hr06c = ($blockcount - $hr06blocks); else $hr06c = 0; echo "| ".fill(number_format($hr06c, 0, ".", ","),9)." blocks in last 6 hrs";echo "    blocks/hr avg: ".($hr06c / 6)."\n";
if (isset($hr12blocks)) $hr12c = ($blockcount - $hr12blocks); else $hr12c = 0; echo "| ".fill(number_format($hr12c, 0, ".", ","),9)." blocks in last 12 hrs";echo "   blocks/hr avg: ".($hr12c / 12)."\n";
if (isset($day1blocks)) $day1c = ($blockcount - $day1blocks); else $day1c = 0; echo "| ".fill(number_format($day1c, 0, ".", ","),9)." blocks in last day";echo "      blocks/hr avg: ".($day1c / 24)."\n";
if (isset($day2blocks)) $day2c = ($blockcount - $day2blocks); else $day2c = 0; echo "| ".fill(number_format($day2c, 0, ".", ","),9)." blocks in last 2 days";echo "   blocks/hr avg: ".($day2c / 48)."\n";
if (isset($day3blocks)) $day3c = ($blockcount - $day3blocks); else $day3c = 0; echo "| ".fill(number_format($day3c, 0, ".", ","),9)." blocks in last 3 days";echo "   blocks/hr avg: ".($day3c / 72)."\n";
if (isset($day4blocks)) $day4c = ($blockcount - $day4blocks); else $day4c = 0; echo "| ".fill(number_format($day4c, 0, ".", ","),9)." blocks in last 4 days";echo "   blocks/hr avg: ".($day4c / 96)."\n";
if (isset($day5blocks)) $day5c = ($blockcount - $day5blocks); else $day5c = 0; echo "| ".fill(number_format($day5c, 0, ".", ","),9)." blocks in last 5 days";echo "   blocks/hr avg: ".($day5c / 120)."\n";
if (isset($day6blocks)) $day6c = ($blockcount - $day6blocks); else $day6c = 0; echo "| ".fill(number_format($day6c, 0, ".", ","),9)." blocks in last 6 days";echo "   blocks/hr avg: ".($day6c / 144)."\n";
if (isset($wk01blocks)) $wk01c = ($blockcount - $wk01blocks); else $wk01c = 0; echo "| ".fill(number_format($wk01c, 0, ".", ","),9)." blocks in last week";echo "     blocks/hr avg: ".($wk01c / 168)."\n";
if (isset($wk02blocks)) $wk02c = ($blockcount - $wk02blocks); else $wk02c = 0; echo "| ".fill(number_format($wk02c, 0, ".", ","),9)." blocks in last 2 wks";echo "    blocks/hr avg: ".($wk02c / 336)."\n";
if (isset($wk03blocks)) $wk03c = ($blockcount - $wk03blocks); else $wk03c = 0; echo "| ".fill(number_format($wk03c, 0, ".", ","),9)." blocks in last 3 wks";echo "    blocks/hr avg: ".($wk03c / 504)."\n";
if (isset($wk04blocks)) $wk04c = ($blockcount - $wk04blocks); else $wk04c = 0; echo "| ".fill(number_format($wk04c, 0, ".", ","),9)." blocks in last 4 wks";echo "    blocks/hr avg: ".($wk04c / 672)."\n";
if (isset($wk08blocks)) $wk08c = ($blockcount - $wk08blocks); else $wk08c = 0; echo "| ".fill(number_format($wk08c, 0, ".", ","),9)." blocks in last 8 wks";echo "    blocks/hr avg: ".($wk08c / 1344)."\n";
if (isset($wk16blocks)) $wk16c = ($blockcount - $wk16blocks); else $wk16c = 0; echo "| ".fill(number_format($wk16c, 0, ".", ","),9)." blocks in last 16 wks";echo "   blocks/hr avg: ".($wk16c / 2688)."\n";
if (isset($wk32blocks)) $wk32c = ($blockcount - $wk32blocks); else $wk32c = 0; echo "| ".fill(number_format($wk32c, 0, ".", ","),9)." blocks in last 32 wks";echo "   blocks/hr avg: ".($wk32c / 5376)."\n";
if (isset($yr1blocks)) $yr1c = ($blockcount - $yr1blocks); else $yr1c = 0; echo "| ".fill(number_format($yr1c, 0, ".", ","),9)." blocks in last year";echo "     blocks/hr avg: ".($yr1c / 8760)."\n";
echo "\----------------------------------------";
if (isset($_GET["showallblocks"])) {
echo "\n\n";
foreach ($block as $key => $num) {
$secs = $block[$key] - $block[$key-1];
$secs .= ($secs == 1) ? " second " : " seconds";
$secs = str_repeat(" ", 14 - strlen($secs)).$secs;
if (isset($block[$key-1])) echo "$secs to find block $key\n";
else echo "  unknown time to find block $key\n";
}
} else {
echo "\\\n   <a href=\"$PHP_SELF?showallblocks\">Timestamp data for all ".number_format($blockcount)." blocks</a>  |\n";
echo "                 ~".number_format(filesize($blockfile) * 1.23175 / 1024 / 1024, 2)."Mb                 |\n";
echo "-----------------------------------------/";
}
function fill($str, $len) { return str_repeat(" ", $len - strlen($str)).$str; }
?>
 </pre></body>
</html>

Additionally, "blockdata" is updated every minute using a cron script written in python.  This python code populates "blockdata" with "<blocknum> <timestamp> <avghashes>"
courtesy of ArtForz

getblockdata.py
Code:
#!/usr/bin/env python
import struct
import hashlib

def uint256_deser(s):
r = 0L
for i in xrange(8):
t = struct.unpack("<I", s[i*4:i*4+4])[0]
r += t << (i * 32)
return r

def uint256_ser(u):
rs = ""
for i in xrange(8):
rs += struct.pack("<I", u & 0xFFFFFFFFL)
u >>= 32
return rs

def uint256_from_compact(c):
nbytes = (c >> 24) & 0xFF
v = (c & 0xFFFFFFL) << (8 * (nbytes - 3))
return v

def get_difficulty(c):
return float(uint256_from_compact(0x1D00FFFF) * 1000 // uint256_from_compact(c)) / 1000.

class CBlock:
def deserialize(self, s):
self.nVersion = struct.unpack("<i", s[0:4])[0]
self.hashPrevBlock = uint256_deser(s[4:36])
self.hashMerkleRoot = uint256_deser(s[36:68])
self.nTime = struct.unpack("<I", s[68:72])[0]
self.nBits = struct.unpack("<I", s[72:76])[0]
self.nNonce = struct.unpack("<I", s[76:80])[0]
h1 = hashlib.sha256(s[0:80]).digest()
self.hash = uint256_deser(hashlib.sha256(h1).digest())
if self.hash > uint256_from_compact(self.nBits):
raise ValueError("bad hash in %s" % repr(self))
self.next = []
self.blocknum = -1
def __repr__(self):
return "CBlock{ver=%08x hp=%064x hm=%064x nt=%08x nb=%08x nn=%08x h=%064x, n=%i}" % (self.nVersion, self.hashPrevBlock, self.hashMerkleRoot, self.nTime, self.nBits, self.nNonce, self.hash, self.blocknum)

def get_chain_len(blk):
r = 1
while len(blk.next) == 1:
blk = blk.next[0]
r += 1
if len(blk.next) > 1:
bestchainlen = 0
for nextblk in blk.next:
chainlen = get_chain_len(nextblk)
if chainlen > bestchainlen:
bestchainlen = chainlen
r += bestchainlen
return r


def readblocks(filename):
f = open(filename, "rb")
blocks = []
idxmap = {}
while True:
try:
magic = f.read(4)
if magic != "\xf9\xbe\xb4\xd9":
break
blklen = struct.unpack("<i", f.read(4))[0]
if blklen < 80:
break
blkdata = f.read(blklen)
if len(blkdata) != blklen:
break
except:
break
blk = CBlock()
blk.deserialize(blkdata)
blocks.append(blk)
idxmap[blk.hash] = blk
if blk.hashPrevBlock:
prevblk = idxmap[blk.hashPrevBlock]
blk.prev = prevblk
prevblk.next.append(blk)
f.close()
rootblk = blocks[0]
del blocks
del idxmap
blk = rootblk
curblkidx = 0
while True:
blk.blocknum = curblkidx
if len(blk.next) == 0:
blk.next = None
break
if len(blk.next) > 1:
bestnextblk = None
bestchainlen = 0
for nextblk in blk.next:
chainlen = get_chain_len(nextblk)
if chainlen > bestchainlen:
bestchainlen = chainlen
bestnextblk = nextblk
elif chainlen == bestchainlen:
if nextblk.nTime < bestnextblk.nTime:
bestchainlen = chainlen
bestnextblk = nextblk
blk.next = [bestnextblk]
blk.next = blk.next[0]
curblkidx += 1
blk = blk.next

blk = rootblk
while blk:
#print "%i %i %.3f 0x%08X" % (blk.blocknum, blk.nTime, get_difficulty(blk.nBits), blk.nBits)
avghashes = 2**256 / uint256_from_compact(blk.nBits)
print "%i %i %i" % (blk.blocknum, blk.nTime, avghashes)
blk = blk.next

if __name__ == "__main__":
print readblocks("/path/to/blk0001.dat")

line for cron
Code:
*/1     *       *       *       *       /path/to/getblockdata.py > /path/to/blockdata


Title: Re: Some Statistics
Post by: knightmb on July 16, 2010, 05:46:10 AM
That's cool, but is the time right on block discovery? My PC army discovered 2 of the last 10 blocks and it took them a lot longer than a few seconds?

[edit] Seems right now, I missed the block by 1 when counting backwards. So cool, blocks are discovered pretty fast. So people don't need mega-fast multi-core systems to win the discovery lotto  ;D


Title: Re: Some Statistics
Post by: mizerydearia on July 16, 2010, 05:48:00 AM
If you have a local ap (apache+php) server, you can run this code and keep it open in browser window and it should update approximately every second.  It isn't 100% precise, but fairly close.

Added: <MacRohard> last=$(date +%s); tail -F debug.log | grep --line-buffered height= | sed -u 's/.*\(height=\(.*\)\)/\2/g' | while read line; do now=$(date +%s); delta=$(( $now - $last)); echo $now $delta $line; last=$now; done


Title: Re: Some Statistics
Post by: mizerydearia on August 03, 2010, 10:11:54 PM
If you have a local ap (apache+php) server, you can run this code and keep it open in browser window and it should update approximately every second.  It isn't 100% precise, but fairly close.

This statement is no longer accurate.  Initially I had been generating my own timestamps based on when the script would see a new block.  Now the timestamp data is extracted from the database and is precise as possible. 


Title: Re: Some Statistics
Post by: mizerydearia on August 07, 2010, 11:45:36 PM
My statistix page now shows moving average
Also, http://nullvoid.org/bitcoin/gnuplot/anim

s == starting block number (default 50)
i == interval (default 1)

e.g. http://nullvoid.org/bitcoin/gnuplot/anim/?s=1000&i=10

I'm pre-generating the images the now, so not all are available yet.
Update: All images are pre-generated

960x720 ~10kb and less per image

The images may change in future if someone suggests additional data for the images that are useful to include in animation sequence.

note: http://nullvoid.org/bitcoin/gnuplot/anim/?s=1000&i=0 if you want to see still image for certain block number/range


Title: Re: Some Statistics
Post by: Insti on August 08, 2010, 08:57:30 AM
You do realize a moving average does not have to be animated, right?

Update: http://nullvoid.org/bitcoin/statistix.php (http://nullvoid.org/bitcoin/statistix.php) has non animated moving averages so I guess you do. :)
The moving average line is a great addition to the graphs!
Thanks.


Title: Re: Some Statistics
Post by: mizerydearia on August 08, 2010, 02:04:28 PM
You do realize a moving average does not have to be animated, right?

Update: http://nullvoid.org/bitcoin/statistix.php (http://nullvoid.org/bitcoin/statistix.php) has non animated moving averages so I guess you do. :)
The moving average line is a great addition to the graphs!
Thanks.

It's a moving moving average! ^_^


Title: Re: Some Statistics
Post by: Tilka on August 08, 2010, 06:05:44 PM
Looks great ;D

EDIT:
And it's getting better every day.


Title: Re: Some Statistics
Post by: mizerydearia on August 08, 2010, 08:57:58 PM
http://nullvoid.org/bitcoin/flot/ <-- This will come out as ~7-8Mb of data, so don't bother using it directly.  My upload bandwith is very limited.

s == start
e == end (takes precedence over length)
l == length

e.g.
start from block 1000 and end at block 1099
http://nullvoid.org/bitcoin/flot/?s=1000&e=1099
http://nullvoid.org/bitcoin/flot/?s=1000&l=100

start from block 73000 and end at current block
http://nullvoid.org/bitcoin/flot/?s=73000

show first 100
http://nullvoid.org/bitcoin/flot/?e=99
http://nullvoid.org/bitcoin/flot/?l=100

This is similar to gnuplot graphs above, except no images and all data is processed locally/client side using flot/javascript.
For large queries (range of 10,000 blocks and higher), expect delays as my upload bandwidth is limited to 768Kb/sec.


Title: Re: Some Statistics
Post by: BeeCee1 on August 09, 2010, 01:32:38 PM
http://nullvoid.org/bitcoin/statistix.php


I'd like to see the current difficulty and the number of blocks to the next adjustment on this page too.


Title: Re: Some Statistics
Post by: mizerydearia on August 10, 2010, 12:40:37 AM
http://nullvoid.org/bitcoin/statistix.php


I'd like to see the current difficulty and the number of blocks to the next adjustment on this page too.

See http://nullvoid.org/bitcoin, which is updated in real-time


Title: Re: Some Statistics
Post by: aceat64 on August 10, 2010, 02:43:08 AM
Awesome work mizerydearia. Do you plan on making most of these scripts open source? If I ever do make that "Bitcoin Command Center" I wouldn't want to be pounding on your server 24/7.  ;D


Title: Re: Some Statistics
Post by: tcatm on August 10, 2010, 02:56:22 AM
The hashtarget is wrong. Also, the font is quite hard to read. letter-spacing: 2px might make it more readable.


Title: Re: Some Statistics
Post by: Ground Loop on August 10, 2010, 05:38:29 AM
One calculation I do for fun (but frequently get wrong) is the total khash/sec rate of the entire bitcoin herd.

If I'm thinking of it correctly, it seems like a long-term average is easily obtained from the current difficulty rating alone.

That is, the difficulty number reflects, to a coarse degree, the gigahash/sec speed of the entire generating workforce, as it was computed at the last adjustment.

From this, and my own aggregate khash/sec total, I can think about how much of the network is my own CPU, and what the odds are that I will generate the next block. :)  Stats for fun.


Title: Re: Some Statistics
Post by: mizerydearia on August 16, 2010, 11:22:33 AM
Thanks to Keefe @ irc for providing block data up to the data displayed.

Here is a frozen collection of data/statistix since unix timestamp 128194750 that may be useful for comparison
http://nullvoid.org/bitcoin/74638/statistix.74638.php (old chain)
http://nullvoid.org/bitcoin/74638/statistix.php (new chain)


Title: Re: Some Statistics
Post by: mizerydearia on August 17, 2010, 05:10:29 PM
http://github.com/mizerydearia/mizerydearia_phpbitcoinscripts


Title: Re: Some Statistics
Post by: Ground Loop on August 17, 2010, 07:18:21 PM
The lower graphs would be much more interesting if they were "truncated" in the Y axis.

It seems a few early long-long-time block generations are squashing all the interesting data down to the bottom two pixel rows.

Maybe log scale?

I'd be curious to see the steps and transitions in the generation rate over time, but it's impossible to see except on the very-short-scale graphs.


Title: Re: Some Statistics
Post by: mizerydearia on August 17, 2010, 10:09:47 PM
I modified statistix.php a bit so that when "showallblocks" is requested the data is flushed to output one by one, and you can stop downloading the data at anytime by pushing escape.  This is useful in case you only want to see the latest blocks and not entire history.

Also, as I have time, I will expand upon the graphs section and produce a page dedicated to graphs of all types.  I'm currently organizing and preparing my code better for release and also pushing updates to the repository.


Title: Re: Some Statistics
Post by: Ground Loop on August 18, 2010, 06:44:00 PM
I'll offer a BTC 100.00 bounty for an addition to
http://nullvoid.org/bitcoin/statistix.php
that shows the inverse (1/x) data: Computing power.

Specifically, total khash/sec for the entire network, based on either current difficulty or (preferably) observed block intervals / moving-average.

How "strong" is the bitcoin community now, and how is it trending?  That's what I'm looking for.  I'm not picky.



Title: Re: Some Statistics
Post by: mizerydearia on August 18, 2010, 07:23:16 PM
How can khash/sec for entire network be determined?


Title: Re: Some Statistics
Post by: lfm on August 18, 2010, 07:53:51 PM
I'll offer a BTC 100.00 bounty for an addition to
http://nullvoid.org/bitcoin/statistix.php
that shows the inverse (1/x) data: Computing power.

Specifically, total khash/sec for the entire network, based on either current difficulty or (preferably) observed block intervals / moving-average.

How "strong" is the bitcoin community now, and how is it trending?  That's what I'm looking for.  I'm not picky.



I think this shows what you want. This is the total difficulty per day. to get total hashes /day multiply by 2^32.



Title: Re: Some Statistics
Post by: Ground Loop on August 18, 2010, 08:02:28 PM
The simplest way is to derive it from the hash target (difficulty).

If you take the present target value
0000000000800e00000000000000000000000000000000000000000000000000
and divide it by the total search space (all 0xF), you get the odds.

In decimal: 5.26786429665E+64 divided by the total search size (2^256) shows you have a one in 2.19e12 chance of finding a new block with every hash try.

We know that the network, as a whole is guided toward 6/hr, and the difficulty reflects that.  If the average generation rate is one every 10 minutes (600 seconds) then we know that the network as a whole is trying
3,663,473,554
hash attempts per second.

So the aggregate network power is around 3,663,473 khash/second.  Call it 3.7 gigahash/sec. :)   Further, if my machine is plugging along at 4,000 khash/sec, then I know I represent about 0.1% of the active network, and have a 1/1000 chance of finding "the next block".

If you use the *actual* recent block find rates (instead of the 10 minute average), which you currently track and graph, then you can see the interesting graph over time of how many total attempts likely produced that result.

I believe the 1/x characteristic would be more interesting to watch for trends than the seconds/block you currently graph, since the number of seconds is forced into a normalized 600 over time.  Total network strength should show an always-upward trend, with some notable spikes, dips, and steps.


Title: Re: Some Statistics
Post by: Ground Loop on August 18, 2010, 09:55:20 PM
I think this shows what you want. This is the total difficulty per day. to get total hashes /day multiply by 2^32.


How does the Difficulty number (511) relate to the hash target?

511.77353426 * 2^32 = 2.2e12 hash/day, or 25 Mhash/sec.  I'm not sure how to interpret that, but it doesn't seem to reflect the 3.7 Ghash/sec total.

Also, the difficulty web page here:
http://www.alloscomp.com/bitcoin/calculator.php

seems to think that 3,600,000 khash/sec is a 10minute average rate.


Title: Re: Some Statistics
Post by: tcatm on August 18, 2010, 10:49:28 PM
How does the Difficulty number (511) relate to the hash target?

Difficulty = 0xFFFF0000000000000000000000000000000000000000000000000000 / HashTarget

For easier calculation you can divide numerator and denominator by 2^193 (i.e. shift right 193 bits).


Title: Re: Some Statistics
Post by: Ground Loop on August 18, 2010, 10:58:24 PM
Ah, I see!  Simpler than I thought.
(difficulty * 2^32) is the odds of a hit on EACH try.
That's the 2.20e12 value again.

So total network power, in hash/sec, is then
(difficulty * 2^32) / 600

Where 600 is a smoothed approximation of last-block-interval-in-seconds.


Title: Re: Some Statistics
Post by: tcatm on August 18, 2010, 11:11:49 PM
So there are about 2000 people generating coins. (1,5Mhash/s average and a 1Ghash/s cluster)


Title: Re: Some Statistics
Post by: mizerydearia on September 27, 2010, 03:07:31 PM
I will be moving over next few days and nullvoid.org and bitbot may be unavailable during this period.  I will try to prepare availability as much as possible.


Title: Re: Some Statistics
Post by: Stephen Gornick on December 06, 2010, 06:52:17 PM
So there are about 2000 people generating coins. (1,5Mhash/s average and a 1Ghash/s cluster)

How did you compute that 2,000 number?  I'ld like to recalc it using the current difficulty.


Title: Re: Some Statistics
Post by: mizerydearia on January 13, 2011, 08:24:32 PM
I will be moving over next few (105?) days and nullvoid.org and bitbot may be unavailable during this period.  I will try to prepare availability as much as possible.

I moved and have reliable/stable Internet access again, thus http://nullvoid.org/bitcoin is available to those that asked about it (and to everyone else).