metrics/test/test.cpp

72 lines
1.6 KiB
C++

#include <iostream>
#include <string>
#include <atomic>
using namespace std;
#include "../lib/metrics.hpp"
using namespace marcelb;
int main() {
// atomic<int> a(0);
// a++;
// cout << a << endl;
Metrics<string> metrika;
cout << " access " << metrika["access"]++ << endl;
cout << " access " << metrika["access"]++ << endl;
cout << " error " << metrika["error"] << endl;
cout << " access " << metrika["access"] << endl;
// metrika.keys();
cout << " error " << metrika["error"] << endl;
cout << " access " << metrika["access"] << endl;
Metrics<uint32_t> metrika2;
enum keys {
access = 1,
error
};
cout << " access " << metrika2[keys::access]++ << endl;
cout << " access " << metrika2[keys::access]++ << endl;
cout << " error " << metrika2[keys::error] << endl;
cout << " access " << metrika2[keys::access] << endl;
// metrika2.keys();
cout << " error " << metrika2[keys::error] << endl;
cout << " access " << metrika2[keys::access] << endl;
// // init
// Metrics stats;
// // operator [] and increment ++
// stats["access"]++;
// // print couter access
// cout << stats["access"];
// // get counters names
// auto listCounterNames = stats.keys();
// // get all couters
// auto data = stats.get_data();
// // reset counters
// stats.clear();
// // set counters
// map<string, uint64_t> MyStats = {{"access", 3},{ "error", 0}};
// stats.set(MyStats);
// // get and clear all counters
// auto dataWithClear = stats.get_data_and_clear();
return 0;
}