]> Git Repo - VerusCoin.git/blame - src/metrics.h
Significant mining optimization and POS DAA modification
[VerusCoin.git] / src / metrics.h
CommitLineData
a6df7ab5
JG
1// Copyright (c) 2016 The Zcash developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
d793f94b
JG
5#include "uint256.h"
6
a6df7ab5 7#include <atomic>
73bf85b4 8#include <mutex>
a6df7ab5
JG
9#include <string>
10
11struct AtomicCounter {
3bddaf63 12 std::atomic<uint64_t> value;
a6df7ab5
JG
13
14 AtomicCounter() : value {0} { }
15
16 void increment(){
17 ++value;
18 }
19
20 void decrement(){
21 --value;
22 }
23
44e17ab3 24 uint64_t get() const {
a6df7ab5
JG
25 return value.load();
26 }
27};
28
73bf85b4
JG
29class AtomicTimer {
30private:
31 std::mutex mtx;
32 uint64_t threads;
33 int64_t start_time;
34 int64_t total_time;
35
36public:
37 AtomicTimer() : threads(0), start_time(0), total_time(0) {}
38
39 /**
40 * Starts timing on first call, and counts the number of calls.
41 */
42 void start();
43
44 /**
45 * Counts number of calls, and stops timing after it has been called as
46 * many times as start().
47 */
48 void stop();
49
50 bool running();
51
0d0265fd
JG
52 uint64_t threadCount();
53
73bf85b4
JG
54 double rate(const AtomicCounter& count);
55};
56
a6df7ab5
JG
57extern AtomicCounter transactionsValidated;
58extern AtomicCounter ehSolverRuns;
e7d59bbc 59extern AtomicCounter solutionTargetChecks;
07be8f7e 60extern AtomicTimer miningTimer;
d793f94b
JG
61
62void TrackMinedBlock(uint256 hash);
a6df7ab5 63
000499ae
JG
64void MarkStartTime();
65double GetLocalSolPS();
047aec1e
JG
66int EstimateNetHeightInner(int height, int64_t tipmediantime,
67 int heightLastCheckpoint, int64_t timeLastCheckpoint,
92bfde0e 68 int64_t genesisTime, int64_t targetSpacing);
000499ae 69
83561c9c
JG
70void TriggerRefresh();
71
4ace963c 72void ConnectMetricsScreen();
a6df7ab5
JG
73void ThreadShowMetricsScreen();
74
75/**
76 * Heart image: https://commons.wikimedia.org/wiki/File:Heart_coraz%C3%B3n.svg
77 * License: CC BY-SA 3.0
78 *
79 * Rendering options:
d934e689
JG
80 * Zcash: img2txt -W 40 -H 20 -f utf8 -d none -g 0.7 Z-yellow.orange-logo.png
81 * Heart: img2txt -W 40 -H 20 -f utf8 -d none 2000px-Heart_corazón.svg.png
a6df7ab5
JG
82 */
83const std::string METRICS_ART =
d934e689
JG
84" \e[0;34;40m \e[0m \n"
85" \e[0;34;40m \e[0m \n"
86" \e[0;34;40m \e[0;31;40m:8\e[0;33;5;40;100m8\e[0;1;30;90;43mSX@888@@X\e[0;31;5;40;100m8\e[0;31;40m:\e[0;34;40m \e[0m \e[0;31;5;41;101m8; %\e[0;1;31;91;41mX\e[0m \e[0;1;31;91;41mX\e[0;31;5;41;101m% ;8\e[0m \n"
87" \e[0;34;40m \e[0;31;40m%\e[0;1;30;90;43m%X\e[0;1;33;93;43mt\e[0;33;5;43;103m%tt%\e[0;1;30;90;43mSSSS\e[0;33;5;43;103mS:\e[0;37;5;43;103mXXX\e[0;1;33;93;43mt\e[0;1;30;90;43m@\e[0;31;40m@\e[0;34;40m \e[0m \e[0;1;31;91;41mX\e[0;31;5;41;101m :\e[0;1;31;91;41m:\e[0m \e[0;1;31;91;41m:\e[0;31;5;41;101m: \e[0;1;31;91;41mX\e[0m \n"
88" \e[0;34;40m \e[0;31;40m@\e[0;1;30;90;43mS\e[0;1;33;93;43m;;tt%%\e[0;33;5;43;103m%\e[0;1;33;93;43mt\e[0;34;40m \e[0;1;33;93;43m;\e[0;33;5;43;103m;::\e[0;37;5;43;103mXXXX\e[0;37;43mS\e[0;31;5;40;100mX\e[0;34;40m \e[0m \e[0;31;5;41;101m% SS %\e[0m \n"
89" \e[0;34;40m \e[0;31;40m.\e[0;1;30;90;43mt\e[0;1;33;93;43m:::;;\e[0;1;30;90;43m%\e[0;31;40m8888\e[0;34;40m \e[0;31;40m8\e[0;30;41m8888\e[0;1;33;93;43mt\e[0;37;5;43;103mXXXX\e[0;1;30;90;43m8\e[0;31;40m;\e[0;34;40m \e[0m \e[0;1;31;91;41mS\e[0;31;5;41;101m \e[0;1;31;91;41mS\e[0m \n"
90" \e[0;34;40m \e[0;31;40m.\e[0;1;30;90;43m%\e[0;1;33;93;43m...:::\e[0;31;40m8\e[0;34;40m \e[0;1;30;90;43m8\e[0;33;5;43;103m::\e[0;37;5;43;103mXXX\e[0;1;33;93;43m%\e[0;31;40m;\e[0;34;40m \e[0m \e[0;31;5;41;101mX X\e[0m \n"
91" \e[0;34;40m \e[0;31;43m8\e[0;1;31;91;43m888\e[0;1;33;93;43m...:\e[0;1;30;90;43mt\e[0;1;30;90;41m888888\e[0;31;40mX\e[0;34;40m \e[0;33;5;40;100m8\e[0;33;5;43;103mt;;::\e[0;37;5;43;103mXX\e[0;1;30;90;43m8\e[0;31;40m \e[0;34;40m \e[0m \e[0;31;5;41;101m8 8\e[0m \n"
92"\e[0;34;40m \e[0;31;40m%\e[0;1;31;91;43m888888\e[0;1;33;93;43m...:::;:\e[0;1;30;90;41m8\e[0;31;40m \e[0;34;40m \e[0;31;40m:\e[0;1;30;90;43mX\e[0;33;5;43;103mttt;;;::\e[0;37;5;43;103mX\e[0;31;5;40;100m@\e[0;34;40m \e[0m \e[0;31;5;41;101m \e[0m \n"
93"\e[0;34;40m \e[0;1;30;90;41m8\e[0;1;31;91;43m88888888\e[0;1;33;93;43m...:\e[0;1;30;90;43mS\e[0;31;40mt\e[0;34;40m \e[0;1;30;90;41m8\e[0;1;33;93;43m:%\e[0;33;5;43;103m%tttt;;;:\e[0;1;30;90;43mX\e[0;34;40m \e[0m \e[0;31;5;41;101mX X\e[0m \n"
94"\e[0;34;40m \e[0;1;30;90;41m8\e[0;1;31;91;43m8888888888\e[0;1;30;90;43mS\e[0;1;30;90;41m8\e[0;31;40m \e[0;34;40m \e[0;31;40m:\e[0;1;30;90;43m%\e[0;1;33;93;43m;ttt%\e[0;33;5;43;103m%tttt;;\e[0;1;30;90;43mX\e[0;34;40m \e[0m \e[0;31;5;41;101m8 8\e[0m \n"
95"\e[0;34;40m \e[0;31;40m%\e[0;1;31;91;43m888888888\e[0;1;30;90;43m%\e[0;31;40mt\e[0;34;40m \e[0;30;41m8\e[0;1;30;90;43mS\e[0;1;33;93;43m:;;;tt%%\e[0;33;5;43;103m%ttt;\e[0;1;30;90;41m8\e[0;34;40m \e[0m \e[0;31;5;41;101m: :\e[0m \n"
96" \e[0;34;40m \e[0;31;43m8t\e[0;1;31;91;43m888888\e[0;33;41m8\e[0;31;40m \e[0;34;40m \e[0;31;40mS\e[0;33;41m888\e[0;31;43m8888\e[0;1;30;90;43mS\e[0;1;33;93;43mtt%%\e[0;33;5;43;103m%t\e[0;1;30;90;43m@\e[0;31;40m \e[0;34;40m \e[0m \e[0;1;31;91;41m:\e[0;31;5;41;101m: :\e[0;1;31;91;41m:\e[0m \n"
97" \e[0;34;40m \e[0;31;40m.\e[0;31;43m@tt\e[0;1;31;91;43m888\e[0;31;43m@\e[0;34;40m \e[0;1;30;90;41m8\e[0;1;33;93;43m;;ttt\e[0;1;30;90;43m@\e[0;31;40m;\e[0;34;40m \e[0m \e[0;31;5;41;101mt t\e[0m \n"
98" \e[0;34;40m \e[0;31;40m.\e[0;31;43m8ttt\e[0;1;31;91;43m8\e[0;31;43m@\e[0;31;40mSSSSS\e[0;34;40m \e[0;31;40mSXXXX\e[0;1;30;90;43m%\e[0;1;33;93;43m:;;;\e[0;1;30;90;43mX\e[0;31;40m;\e[0;34;40m \e[0m \e[0;31;5;41;101m8 8\e[0m \n"
99" \e[0;34;40m \e[0;31;40mX\e[0;31;43m8ttt\e[0;1;31;91;43m8888\e[0;1;30;90;43m%\e[0;34;40m \e[0;1;30;90;43m%\e[0;1;31;91;43m88\e[0;1;33;93;43m...::\e[0;1;30;90;43mX\e[0;30;41m8\e[0;31;40m \e[0;34;40m \e[0m \e[0;1;31;91;41mX\e[0;31;5;41;101m. .\e[0;1;31;91;41mX\e[0m \n"
100" \e[0;34;40m \e[0;31;40m%\e[0;1;30;90;41m8\e[0;31;43m@tt\e[0;1;31;91;43m88\e[0;31;43m;\e[0;33;41m8888\e[0;1;30;90;43m%\e[0;1;31;91;43m8888\e[0;1;30;90;43m%\e[0;31;43m8\e[0;31;40mX\e[0;32;40m \e[0;34;40m \e[0m \e[0;1;31;91;41m:\e[0;31;5;41;101m; ;\e[0;1;31;91;41m:\e[0m \n"
101" \e[0;34;40m \e[0;31;40m:@\e[0;1;30;90;41m8\e[0;33;41m8\e[0;31;43m8@XXX@8\e[0;1;30;90;41m8\e[0;31;40m8:\e[0;34;40m \e[0m \e[0;31;5;41;101mtt\e[0m \n"
102" \e[0;34;40m \e[0m \n"
103" \e[0;34;40m \e[0m ";
This page took 0.080564 seconds and 4 git commands to generate.