Add get_data methodes

dev v0.2
marcelb 11 months ago
parent 2431e4b9bc
commit 8210800683
  1. 6
      .vscode/settings.json
  2. 11
      lib/metrics.hpp
  3. 11
      src/metrics.cpp
  4. BIN
      test/test
  5. 1
      test/test.cpp

@ -4,6 +4,10 @@
"ostream": "cpp", "ostream": "cpp",
"string": "cpp", "string": "cpp",
"vector": "cpp", "vector": "cpp",
"map": "cpp" "map": "cpp",
"*.tcc": "cpp",
"deque": "cpp",
"unordered_map": "cpp",
"system_error": "cpp"
} }
} }

@ -54,6 +54,17 @@ class Metrics {
*/ */
vector<string> keys(); vector<string> keys();
/**
* Metoda vraća map<string, uint> svih mjerenja
*/
map<string, uint> get_data();
/**
* Metoda vraća map<string, uint> svih mjerenja i resetira brojače
*/
map<string, uint> get_data_and_clear();
}; };

@ -22,3 +22,14 @@ vector<string> marcelb::Metrics::keys() {
return _keys; return _keys;
} }
map<string, uint> marcelb::Metrics::get_data() {
return counters;
}
map<string, uint> marcelb::Metrics::get_data_and_clear() {
auto data = counters;
clear();
return counters;
}

Binary file not shown.

@ -17,5 +17,6 @@ int main() {
cout << " access " << metrika["access"] << endl; cout << " access " << metrika["access"] << endl;
return 0; return 0;
} }
Loading…
Cancel
Save