Stats.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. This file is part of cpp-ethereum.
  3. cpp-ethereum is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. cpp-ethereum is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #pragma once
  15. #include <chrono>
  16. #include <vector>
  17. #include "TestHelper.h"
  18. namespace dev
  19. {
  20. namespace test
  21. {
  22. class Stats: public Listener
  23. {
  24. public:
  25. using clock = std::chrono::high_resolution_clock;
  26. struct Item
  27. {
  28. clock::duration duration;
  29. int64_t gasUsed;
  30. std::string name;
  31. };
  32. static Stats& get();
  33. ~Stats();
  34. void suiteStarted(std::string const& _name) override;
  35. void testStarted(std::string const& _name) override;
  36. void testFinished(int64_t _gasUsed) override;
  37. private:
  38. clock::time_point m_tp;
  39. std::string m_currentSuite;
  40. std::string m_currentTest;
  41. std::vector<Item> m_stats;
  42. };
  43. }
  44. }