]> Git Repo - VerusCoin.git/blob - src/metrics.h
Test
[VerusCoin.git] / src / metrics.h
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
5 #include "uint256.h"
6
7 #include <atomic>
8 #include <mutex>
9 #include <string>
10
11 struct AtomicCounter {
12     std::atomic<uint64_t> value;
13
14     AtomicCounter() : value {0} { }
15
16     void increment(){
17         ++value;
18     }
19
20     void decrement(){
21         --value;
22     }
23
24     int get() const {
25         return value.load();
26     }
27 };
28
29 class AtomicTimer {
30 private:
31     std::mutex mtx;
32     uint64_t threads;
33     int64_t start_time;
34     int64_t total_time;
35
36 public:
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
52     double rate(const AtomicCounter& count);
53 };
54
55 extern AtomicCounter transactionsValidated;
56 extern AtomicCounter ehSolverRuns;
57 extern AtomicCounter solutionTargetChecks;
58 extern AtomicTimer miningTimer;
59
60 void TrackMinedBlock(uint256 hash);
61
62 void MarkStartTime();
63 double GetLocalSolPS();
64
65 void TriggerRefresh();
66
67 void ConnectMetricsScreen();
68 void ThreadShowMetricsScreen();
69
70 /**
71  * Heart image: https://commons.wikimedia.org/wiki/File:Heart_coraz%C3%B3n.svg
72  * License: CC BY-SA 3.0
73  *
74  * Rendering options:
75  * Zcash: img2txt -W 40 -H 20 -f utf8 -d none -g 0.7 Z-yellow.orange-logo.png
76  * Heart: img2txt -W 40 -H 20 -f utf8 -d none 2000px-Heart_corazón.svg.png
77  */
78 const std::string METRICS_ART =
79 "              \e[0;34;40m            \e[0m                                                      \n"
80 "          \e[0;34;40m                    \e[0m                                                  \n"
81 "       \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"
82 "     \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"
83 "   \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"
84 "  \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"
85\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"
86\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"
87 "\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"
88 "\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"
89 "\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"
90 "\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"
91\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"
92\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"
93 "  \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"
94 "   \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"
95 "     \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"
96 "       \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"
97 "         \e[0;34;40m                      \e[0m                                                 \n"
98 "              \e[0;34;40m             \e[0m                                                     ";
This page took 0.030525 seconds and 4 git commands to generate.