Merge pull request #2 from donSchoe/master

Improved statistics output for better readability.
master
Thomas Baumbach 2013-10-20 10:29:32 -07:00
commit aa92b7b925
3 changed files with 31 additions and 26 deletions

View File

@ -5,6 +5,7 @@ file COPYING or http://www.opensource.org/licenses/mit-license.php.
This product includes software developed by the OpenSSL Project for use in the [OpenSSL Toolkit](http://www.openssl.org/). This product includes This product includes software developed by the OpenSSL Project for use in the [OpenSSL Toolkit](http://www.openssl.org/). This product includes
cryptographic software written by Eric Young ([eay@cryptsoft.com](mailto:eay@cryptsoft.com)), and UPnP software written by Thomas Bernard. cryptographic software written by Eric Young ([eay@cryptsoft.com](mailto:eay@cryptsoft.com)), and UPnP software written by Thomas Bernard.
UNIX BUILD NOTES UNIX BUILD NOTES
==================== ====================
@ -14,8 +15,6 @@ To Build
cd src/ cd src/
make -f makefile.unix # Headless bitcoin make -f makefile.unix # Headless bitcoin
See readme-qt.rst for instructions on building Bitcoin-Qt, the graphical user interface.
Dependencies Dependencies
--------------------- ---------------------
@ -24,6 +23,7 @@ Dependencies
libssl SSL Support Secure communications libssl SSL Support Secure communications
libdb4.8 Berkeley DB Blockchain & wallet storage libdb4.8 Berkeley DB Blockchain & wallet storage
libboost Boost C++ Library libboost Boost C++ Library
libgmp Gnu MP Multiprecision arithmetic library developers tools
miniupnpc UPnP Support Optional firewall-jumping support miniupnpc UPnP Support Optional firewall-jumping support
[miniupnpc](http://miniupnp.free.fr/) may be used for UPnP port mapping. It can be downloaded from [here]( [miniupnpc](http://miniupnp.free.fr/) may be used for UPnP port mapping. It can be downloaded from [here](
@ -48,15 +48,16 @@ Licenses of statically linked libraries:
- GCC 4.3.3 - GCC 4.3.3
- OpenSSL 1.0.1c - OpenSSL 1.0.1c
- Berkeley DB 4.8.30.NC - Berkeley DB 4.8.30.NC
- Boost 1.37 - Boost 1.48
- GMP 5.0.2
- miniupnpc 1.6 - miniupnpc 1.6
Dependency Build Instructions: Ubuntu & Debian Dependency Build Instructions: Ubuntu & Debian
---------------------------------------------- ----------------------------------------------
Build requirements: Build requirements:
sudo apt-get install build-essential sudo apt-get install build-essential libssl-dev
sudo apt-get install libssl-dev
for Ubuntu 12.04: for Ubuntu 12.04:
@ -69,9 +70,12 @@ for Ubuntu 12.04:
for other Ubuntu & Debian: for other Ubuntu & Debian:
sudo apt-get install libgmp-dev
sudo apt-get install libdb4.8-dev sudo apt-get install libdb4.8-dev
sudo apt-get install libdb4.8++-dev sudo apt-get install libdb4.8++-dev
sudo apt-get install libboost1.37-dev sudo apt-get install libboost1.48-dev
sudo apt-get install libboost-timer1.48-dev
sudo apt-get install libboost-chrono1.48-dev
(If using Boost 1.37, append -mt to the boost libraries in the makefile) (If using Boost 1.37, append -mt to the boost libraries in the makefile)
Optional: Optional:

View File

@ -2203,7 +2203,7 @@ bool CBlock::AcceptBlock(CValidationState &state, CDiskBlockPos *dbp)
// Get block work value for main chain protocol // Get block work value for main chain protocol
CBigNum CBlockIndex::GetBlockWork() const CBigNum CBlockIndex::GetBlockWork() const
{ {
// Primecoin: // Primecoin:
// Difficulty multiplier of extra prime is estimated by nWorkTransitionRatio // Difficulty multiplier of extra prime is estimated by nWorkTransitionRatio
// Difficulty multiplier of fractional is estimated by // Difficulty multiplier of fractional is estimated by
// r = 1/TransitionRatio // r = 1/TransitionRatio
@ -4592,7 +4592,7 @@ void BitcoinMiner(CWallet *pwallet, CBlockProvider *block_provider, unsigned int
CBlock *pblock = NULL; CBlock *pblock = NULL;
uint256 old_hash; uint256 old_hash;
unsigned int old_nonce = 0; unsigned int old_nonce = 0;
try { loop { try { loop {
while (block_provider == NULL && vNodes.empty()) while (block_provider == NULL && vNodes.empty())
MilliSleep(1000); MilliSleep(1000);
@ -4602,7 +4602,7 @@ void BitcoinMiner(CWallet *pwallet, CBlockProvider *block_provider, unsigned int
// //
unsigned int nTransactionsUpdatedLast = nTransactionsUpdated; unsigned int nTransactionsUpdatedLast = nTransactionsUpdated;
CBlockIndex* pindexPrev = pindexBest; CBlockIndex* pindexPrev = pindexBest;
auto_ptr<CBlockTemplate> pblocktemplate; auto_ptr<CBlockTemplate> pblocktemplate;
if (block_provider == NULL) { if (block_provider == NULL) {
pblocktemplate = auto_ptr<CBlockTemplate>(CreateNewBlock(reservekey)); pblocktemplate = auto_ptr<CBlockTemplate>(CreateNewBlock(reservekey));
@ -4711,7 +4711,7 @@ void BitcoinMiner(CWallet *pwallet, CBlockProvider *block_provider, unsigned int
old_nonce = pblock->nNonce + 1; old_nonce = pblock->nNonce + 1;
break; break;
} }
/// ///
/// ENABLE the following code, if you need data for the perftool /// ENABLE the following code, if you need data for the perftool
/// ///
@ -4720,23 +4720,23 @@ void BitcoinMiner(CWallet *pwallet, CBlockProvider *block_provider, unsigned int
static CCriticalSection cs; static CCriticalSection cs;
{ {
LOCK(cs); LOCK(cs);
std::ofstream output_file("miner_data"); std::ofstream output_file("miner_data");
std::ofstream output_file_block("miner_data.blk", std::ofstream::out | std::ofstream::binary); std::ofstream output_file_block("miner_data.blk", std::ofstream::out | std::ofstream::binary);
::Serialize(output_file_block, *pblock, 0, 0); //writeblock ::Serialize(output_file_block, *pblock, 0, 0); //writeblock
output_file << mpzFixedMultiplier.get_str(10) << std::endl; output_file << mpzFixedMultiplier.get_str(10) << std::endl;
output_file << fNewBlock << std::endl; output_file << fNewBlock << std::endl;
output_file << nTriedMultiplier << std::endl; output_file << nTriedMultiplier << std::endl;
output_file << nPrimorialMultiplier << std::endl; output_file << nPrimorialMultiplier << std::endl;
output_file << mpzHash.get_str(10) << std::endl; output_file << mpzHash.get_str(10) << std::endl;
output_file.close(); output_file.close();
output_file_block.close(); output_file_block.close();
} }
}*/ }*/
nRoundTests += nTests; nRoundTests += nTests;
nRoundPrimesHit += nPrimesHit; nRoundPrimesHit += nPrimesHit;
@ -4776,7 +4776,7 @@ void BitcoinMiner(CWallet *pwallet, CBlockProvider *block_provider, unsigned int
{ {
double dPrimesPerMinute = 60000.0 * nPrimeCounter / (nMillisNow - nHPSTimerStart); double dPrimesPerMinute = 60000.0 * nPrimeCounter / (nMillisNow - nHPSTimerStart);
dPrimesPerSec = dPrimesPerMinute / 60.0; dPrimesPerSec = dPrimesPerMinute / 60.0;
double dTestsPerMinute = 60000.0 * nTestCounter / (nMillisNow - nHPSTimerStart); double dTestsPerSec = 1000.0 * nTestCounter / (nMillisNow - nHPSTimerStart);
dChainsPerMinute = 60000.0 * nChainCounter / (nMillisNow - nHPSTimerStart); dChainsPerMinute = 60000.0 * nChainCounter / (nMillisNow - nHPSTimerStart);
dChainsPerDay = 86400000.0 * dChainExpected / (GetTimeMillis() - nHPSTimerStart); dChainsPerDay = 86400000.0 * dChainExpected / (GetTimeMillis() - nHPSTimerStart);
nHPSTimerStart = nMillisNow; nHPSTimerStart = nMillisNow;
@ -4788,12 +4788,12 @@ void BitcoinMiner(CWallet *pwallet, CBlockProvider *block_provider, unsigned int
if (nMillisNow - nLogTime > 59000) if (nMillisNow - nLogTime > 59000)
{ {
nLogTime = nMillisNow; nLogTime = nMillisNow;
printf("%s primemeter %9.0f prime/h %9.0f test/h %4.0f %d-chains/h %3.6f chain/d\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", nLogTime / 1000).c_str(), dPrimesPerMinute * 60.0, dTestsPerMinute * 60.0, dChainsPerMinute * 60.0, nStatsChainLength, dChainsPerDay); printf("[STATS] %s | %4.0f primes/s, %4.0f tests/s, %4.0f %d-chains/h, %3.3f chains/d\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", nLogTime / 1000).c_str(), dPrimesPerSec, dTestsPerSec, dChainsPerMinute * 60.0, nStatsChainLength, dChainsPerDay);
} }
} }
} }
} }
old_nonce = pblock->nNonce; old_nonce = pblock->nNonce;
// Check for stop or if block needs to be rebuilt // Check for stop or if block needs to be rebuilt
@ -4810,7 +4810,7 @@ void BitcoinMiner(CWallet *pwallet, CBlockProvider *block_provider, unsigned int
block_provider->forceReconnect(); block_provider->forceReconnect();
nStart = GetTime(); nStart = GetTime();
} }
if (fNewBlock) //aka: sieve's done, we need a updated nonce if (fNewBlock) //aka: sieve's done, we need a updated nonce
{ {
// Primecoin: a sieve+primality round completes // Primecoin: a sieve+primality round completes
// Primecoin: estimate time to block // Primecoin: estimate time to block
@ -4819,7 +4819,7 @@ void BitcoinMiner(CWallet *pwallet, CBlockProvider *block_provider, unsigned int
// Make sure the estimated time is very high if only 0 primes were found // Make sure the estimated time is very high if only 0 primes were found
if (nRoundPrimesHit == 0) if (nRoundPrimesHit == 0)
nCalcRoundTests *= 1000; nCalcRoundTests *= 1000;
int64 nRoundTime = (GetTimeMicros() - nPrimeTimerStart); int64 nRoundTime = (GetTimeMicros() - nPrimeTimerStart);
dTimeExpected = (double) nRoundTime / nCalcRoundTests; dTimeExpected = (double) nRoundTime / nCalcRoundTests;
double dRoundChainExpected = (double) nRoundTests; double dRoundChainExpected = (double) nRoundTests;
for (unsigned int n = 0, nTargetLength = TargetGetLength(pblock->nBits); n < nTargetLength; n++) for (unsigned int n = 0, nTargetLength = TargetGetLength(pblock->nBits); n < nTargetLength; n++)
@ -4839,7 +4839,7 @@ void BitcoinMiner(CWallet *pwallet, CBlockProvider *block_provider, unsigned int
// Primecoin: update time and nonce // Primecoin: update time and nonce
//pblock->nTime = max(pblock->nTime, (unsigned int) GetAdjustedTime()); //pblock->nTime = max(pblock->nTime, (unsigned int) GetAdjustedTime());
pblock->nTime = max(pblock->nTime, (unsigned int)(((((size_t)GetAdjustedTime() + thread_num_max) / thread_num_max) * thread_num_max) + thread_id)); pblock->nTime = max(pblock->nTime, (unsigned int)(((((size_t)GetAdjustedTime() + thread_num_max) / thread_num_max) * thread_num_max) + thread_id));
pblock->nNonce++; pblock->nNonce++;
loop { loop {
// Fast loop // Fast loop

View File

@ -416,7 +416,7 @@ private:
void stats_running() { void stats_running() {
if (!running) return; if (!running) return;
std::cout << std::fixed; std::cout << std::fixed;
std::cout << std::setprecision(0); std::cout << std::setprecision(1);
boost::posix_time::ptime t_end = boost::posix_time::second_clock::universal_time(); boost::posix_time::ptime t_end = boost::posix_time::second_clock::universal_time();
unsigned long rejects = 0; unsigned long rejects = 0;
unsigned long stale = 0; unsigned long stale = 0;
@ -428,11 +428,12 @@ private:
if (it->first == 1) blocks = it->second; if (it->first == 1) blocks = it->second;
if (it->first > 1) valid += it->second; if (it->first > 1) valid += it->second;
} }
std::cout << "[STATS] " << DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTimeMillis() / 1000).c_str() << " | ";
for (std::map<int,unsigned long>::iterator it = statistics.begin(); it != statistics.end(); ++it) for (std::map<int,unsigned long>::iterator it = statistics.begin(); it != statistics.end(); ++it)
if (it->first > 1) if (it->first > 1)
std::cout << " " << it->first << "-CH: " << it->second << " (" << std::cout << it->first << "-CH: " << it->second << " (" <<
((valid+blocks > 0) ? (static_cast<double>(it->second) / static_cast<double>(valid+blocks)) * 100.0 : 0.0) << "% | " << ((valid+blocks > 0) ? (static_cast<double>(it->second) / static_cast<double>(valid+blocks)) * 100.0 : 0.0) << "% | " <<
((valid+blocks > 0) ? (static_cast<double>(it->second) / (static_cast<double>((t_end - t_start).total_seconds()) / 3600.0)) : 0.0) << "/hr), "; ((valid+blocks > 0) ? (static_cast<double>(it->second) / (static_cast<double>((t_end - t_start).total_seconds()) / 3600.0)) : 0.0) << "/h), ";
if (valid+blocks+rejects+stale > 0) { if (valid+blocks+rejects+stale > 0) {
std::cout << "VL: " << valid+blocks << " (" << (static_cast<double>(valid+blocks) / static_cast<double>(valid+blocks+rejects+stale)) * 100.0 << "%), "; std::cout << "VL: " << valid+blocks << " (" << (static_cast<double>(valid+blocks) / static_cast<double>(valid+blocks+rejects+stale)) * 100.0 << "%), ";
std::cout << "RJ: " << rejects << " (" << (static_cast<double>(rejects) / static_cast<double>(valid+blocks+rejects+stale)) * 100.0 << "%), "; std::cout << "RJ: " << rejects << " (" << (static_cast<double>(rejects) / static_cast<double>(valid+blocks+rejects+stale)) * 100.0 << "%), ";
@ -467,13 +468,13 @@ void stats_on_exit() {
} }
std::cout << std::endl; std::cout << std::endl;
std::cout << "********************************************" << std::endl; std::cout << "********************************************" << std::endl;
std::cout << "*** running time: " << static_cast<double>((t_end - t_start).total_seconds()) / 3600.0 << "hrs" << std::endl; std::cout << "*** running time: " << static_cast<double>((t_end - t_start).total_seconds()) / 3600.0 << "h" << std::endl;
std::cout << "***" << std::endl; std::cout << "***" << std::endl;
for (std::map<int,unsigned long>::iterator it = statistics.begin(); it != statistics.end(); ++it) for (std::map<int,unsigned long>::iterator it = statistics.begin(); it != statistics.end(); ++it)
if (it->first > 1) if (it->first > 1)
std::cout << "*** " << it->first << "-chains: " << it->second << "\t(" << std::cout << "*** " << it->first << "-chains: " << it->second << "\t(" <<
((valid+blocks > 0) ? (static_cast<double>(it->second) / static_cast<double>(valid+blocks)) * 100.0 : 0.0) << "% | " << ((valid+blocks > 0) ? (static_cast<double>(it->second) / static_cast<double>(valid+blocks)) * 100.0 : 0.0) << "% | " <<
((valid+blocks > 0) ? (static_cast<double>(it->second) / (static_cast<double>((t_end - t_start).total_seconds()) / 3600.0)) : 0.0) << "/hr)" << ((valid+blocks > 0) ? (static_cast<double>(it->second) / (static_cast<double>((t_end - t_start).total_seconds()) / 3600.0)) : 0.0) << "/h)" <<
std::endl; std::endl;
if (valid+blocks+rejects+stale > 0) { if (valid+blocks+rejects+stale > 0) {
std::cout << "***" << std::endl; std::cout << "***" << std::endl;