From ef39684d76388d4a0d85df6d126524b47cc31008 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Radovan=20=C4=8Cerven=C3=BD?= <radovan.cerveny@gmail.com>
Date: Tue, 9 Feb 2016 16:59:05 +0100
Subject: [PATCH] removed old measurements

---
 alib2std/src/chrono                         |  13 --
 alib2std/src/extensions/chrono.cpp          | 136 -------------------
 alib2std/src/extensions/chrono.hpp          | 139 --------------------
 alib2std/test-src/extensions/ChronoTest.cpp |  74 -----------
 alib2std/test-src/extensions/ChronoTest.h   |  21 ---
 5 files changed, 383 deletions(-)
 delete mode 100644 alib2std/src/chrono
 delete mode 100644 alib2std/src/extensions/chrono.cpp
 delete mode 100644 alib2std/src/extensions/chrono.hpp
 delete mode 100644 alib2std/test-src/extensions/ChronoTest.cpp
 delete mode 100644 alib2std/test-src/extensions/ChronoTest.h

diff --git a/alib2std/src/chrono b/alib2std/src/chrono
deleted file mode 100644
index 551a83d542..0000000000
--- a/alib2std/src/chrono
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef __CHRONO_HEADER_WRAPPER_
-#define __CHRONO_HEADER_WRAPPER_
-
-#include <bits/../chrono>
-#include "vector"
-#include "set"
-#include "map"
-#include "deque"
-#include "exception"
-#include "tuple"
-#include "extensions/chrono.hpp"
-
-#endif /* __CHRONO_HEADER_WRAPPER_ */
diff --git a/alib2std/src/extensions/chrono.cpp b/alib2std/src/extensions/chrono.cpp
deleted file mode 100644
index 66eafc1899..0000000000
--- a/alib2std/src/extensions/chrono.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * chrono.cpp
- *
- * Created on: Apr 1, 2013
- * Author: Jan Travnicek
- */
-
-#include "../chrono"
-
-namespace std {
-
-namespace chrono {
-
-measurements measurements::INSTANCE;
-
-measurements::Format measurements::Format::LIST = { 0 };
-measurements::Format measurements::Format::TREE = { 1 };
-
-measurements::Filter measurements::Filter::ALL = { true, ~0u };
-measurements::Filter measurements::Filter::NONE = { false, ~0u };
-measurements::Filter measurements::Filter::OVERALL = { true, measurements::Type::OVERALL };
-measurements::Filter measurements::Filter::NO_OVERALL = { false, measurements::Type::OVERALL };
-measurements::Filter measurements::Filter::INIT = { true, measurements::Type::INIT };
-measurements::Filter measurements::Filter::NO_INIT = { false, measurements::Type::INIT };
-measurements::Filter measurements::Filter::FINALIZE = { true, measurements::Type::FINALIZE };
-measurements::Filter measurements::Filter::NO_FINALIZE = { false, measurements::Type::FINALIZE };
-measurements::Filter measurements::Filter::MAIN = { true, measurements::Type::MAIN };
-measurements::Filter measurements::Filter::NO_MAIN = { false, measurements::Type::MAIN };
-measurements::Filter measurements::Filter::AUXILIARY = { true, measurements::Type::AUXILIARY };
-measurements::Filter measurements::Filter::NO_AUXILIARY = { false, measurements::Type::AUXILIARY };
-
-const int measurements::measurements_format_index = std::ios::xalloc();
-const int measurements::measurements_filter_index = std::ios::xalloc();
-
-void printAsList(std::ostream& out, const measurements::Results& data, unsigned index) {
-	const unsigned filter = out.iword(measurements::measurements_filter_index);
-
-	if(data.results.size() - 1 != index) out << ", ";
-	if((std::get<1>(data[index]) & filter) == 0) out << data[index];
-	for(unsigned idx : std::get<4>(data[index])) {
-		printAsList(out, data, idx);
-	}
-}
-
-void subtreeSizes(std::ostream& out, const measurements::Results& data, unsigned index, std::map<unsigned, unsigned>& res) {
-	res[index] = 0;
-
-	const unsigned filter = out.iword(measurements::measurements_filter_index);
-	if((std::get<1>(data[index]) & filter) == 0) res[index] += 1;
-
-	for(unsigned idx : std::get<4>(data[index])) {
-		subtreeSizes(out, data, idx, res);
-		res[index] += res[idx];
-	}
-}
-
-void printAsTree(std::ostream& out, std::string& prefix, map<unsigned, unsigned>& indexToSize, const measurements::Results& data, unsigned index, bool last) {
-	const unsigned filter = out.iword(measurements::measurements_filter_index);
-	if((std::get<1>(data[index]) & filter) == 0) {
-		if(last) prefix[prefix.size() - 2] = '\\';
-		if(indexToSize[index] != 1) prefix += "+";
-
-		out << prefix << data[index] << std::endl;
-
-		if(indexToSize[index] == 1) prefix += "-";
-		prefix += "-";
-		if(last) prefix[prefix.size() - 4] = ' ';
-		prefix[prefix.size() - 3] = ' ';
-		prefix[prefix.size() - 2] = '|';
-
-		unsigned size = std::get<4>(data[index]).size();
-		for(unsigned idx : std::get<4>(data[index])) {
-			printAsTree(out, prefix, indexToSize, data, idx, size == 1);
-			size--;
-		}
-		prefix[prefix.size() - 3] = '-';
-
-		prefix.pop_back();
-		prefix.pop_back();
-	} else {
-		unsigned size = std::get<4>(data[index]).size();
-		for(unsigned idx : std::get<4>(data[index])) {
-			printAsTree(out, prefix, indexToSize, data, idx, size == 1 && last);
-			size --;
-		}
-	}
-}
-
-std::ostream& operator<<(std::ostream& out, const measurements::Results& data) {
-	const unsigned format = out.iword(measurements::measurements_format_index);
-
-	unsigned index = data.results.size() - 1;
-	if(format == measurements::Format::LIST.type) {
-		printAsList(out, data, index);
-	} else {
-		std::string prefix = "|-";
-		std::map<unsigned, unsigned> indexToSize;
-		subtreeSizes(out, data, index, indexToSize);
-
-		printAsTree(out, prefix, indexToSize, data, index, true);
-	}
-
-//	out << format << " " << filter << " " << data.results;
-	return out;
-}
-
-std::ostream& operator<<(std::ostream& out, microseconds time) {
-	out << time.count() << "ms";
-	return out;
-}
-
-std::ostream& operator<<(std::ostream& out, measurements::Type type) {
-	switch(type) {
-	case measurements::Type::INIT:
-		out << "INIT";
-		break;
-	case measurements::Type::FINALIZE:
-		out << "FINALIZE";
-		break;
-	case measurements::Type::MAIN:
-		out << "MAIN";
-		break;
-	case measurements::Type::AUXILIARY:
-		out << "AUXILIARY";
-		break;
-	case measurements::Type::OVERALL:
-		out << "OVERALL";
-		break;
-	}
-	return out;
-}
-
-} /* namespace chrono */
-
-} /* namespace std */
-
diff --git a/alib2std/src/extensions/chrono.hpp b/alib2std/src/extensions/chrono.hpp
deleted file mode 100644
index 8567fe74da..0000000000
--- a/alib2std/src/extensions/chrono.hpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * clone.hpp
- *
- * Created on: Apr 1, 2013
- * Author: Jan Travnicek
- */
-
-#ifndef CHRONO_HPP_
-#define CHRONO_HPP_
-
-namespace std {
-
-namespace chrono {
-
-class measure_duration {
-	time_point<system_clock> m_Start;
-	time_point<system_clock> m_End;
-
-public:
-	void start() {
-		m_Start = system_clock::now();
-	}
-
-	void end() {
-		m_End = system_clock::now();
-	}
-
-	microseconds duration() {
-		return duration_cast<microseconds>(m_End - m_Start);
-	}
-
-};
-
-class measurements {
-public:
-	enum Type {
-		OVERALL = 1,
-		INIT = 2,
-		FINALIZE = 4,
-		MAIN = 8,
-		AUXILIARY = 16
-	};
-
-	struct Format {
-		unsigned type;
-
-		static Format LIST;
-		static Format TREE;
-	};
-
-	struct Filter {
-		bool set;
-		unsigned val;
-
-		static Filter ALL;
-		static Filter NONE;
-		static Filter OVERALL;
-		static Filter NO_OVERALL;
-		static Filter INIT;
-		static Filter NO_INIT;
-		static Filter FINALIZE;
-		static Filter NO_FINALIZE;
-		static Filter MAIN;
-		static Filter NO_MAIN;
-		static Filter AUXILIARY;
-		static Filter NO_AUXILIARY;
-
-	};
-
-	struct Results {
-		const std::vector<std::tuple<std::string, measurements::Type, microseconds, microseconds, std::set<unsigned>>>& results;
-
-		const std::tuple<std::string, measurements::Type, microseconds, microseconds, std::set<unsigned>>& operator[](int idx) const {
-			return results[idx];
-		}
-	};
-
-	static const int measurements_format_index;
-	static const int measurements_filter_index;
-
-private:
-	std::vector<std::tuple<std::string, measurements::Type, microseconds, microseconds, std::set<unsigned>>> measurements_vector; // name, type, complete duration, real duration
-	std::deque<std::tuple<std::string, measurements::Type, time_point<system_clock>, microseconds, std::set<unsigned>>> measurements_stack; // name, type, start, sub measurements duration
-
-	static measurements INSTANCE;
-
-public:
-	static void start(std::string name, measurements::Type type) {
-		INSTANCE.measurements_stack.emplace_back(std::move(name), type, system_clock::now(), microseconds(0), std::set<unsigned>{});
-	}
-
-	static void end() {
-		if(INSTANCE.measurements_stack.empty()) throw std::logic_error("no measurement started");
-
-		std::tuple<std::string, measurements::Type, time_point<system_clock>, microseconds, std::set<unsigned>> current = std::move(INSTANCE.measurements_stack.back());
-		INSTANCE.measurements_stack.pop_back();
-
-		microseconds dur = duration_cast<microseconds>(system_clock::now() - std::get<2>(current));
-
-		unsigned index = INSTANCE.measurements_vector.size();
-		INSTANCE.measurements_vector.emplace_back(std::move(std::get<0>(current)), std::get<1>(current), dur, dur - std::get<3>(current), std::get<4>(current));
-		if(!INSTANCE.measurements_stack.empty()) {
-			std::get<3>(INSTANCE.measurements_stack.back()) += std::get<2>(INSTANCE.measurements_vector.back());
-			std::get<4>(INSTANCE.measurements_stack.back()).insert(index);
-		}
-	}
-
-	static Results results() {
-		return { INSTANCE.measurements_vector };
-	}
-
-};
-
-std::ostream& operator<<(std::ostream& out, const measurements::Results& data);
-
-std::ostream& operator<<(std::ostream& out, microseconds time);
-
-std::ostream& operator<<(std::ostream& out, measurements::Type type);
-
-template<typename _CharT, typename _Traits>
-inline basic_ostream<_CharT, _Traits>& operator <<( basic_ostream<_CharT, _Traits>& x, measurements::Format f) {
-	x.iword(measurements::measurements_format_index) = f.type;
-	return x;
-}
-
-template<typename _CharT, typename _Traits>
-inline basic_ostream<_CharT, _Traits>& operator <<( basic_ostream<_CharT, _Traits>& x, measurements::Filter f) {
-	if(f.set)
-		x.iword(measurements::measurements_filter_index) &= ~f.val;
-	else
-		x.iword(measurements::measurements_filter_index) |= f.val;
-	return x;
-}
-
-} /* namespace chrono */
-
-} /* namespace std */
-
-#endif /* CHRONO_HPP_ */
diff --git a/alib2std/test-src/extensions/ChronoTest.cpp b/alib2std/test-src/extensions/ChronoTest.cpp
deleted file mode 100644
index e64b6e7841..0000000000
--- a/alib2std/test-src/extensions/ChronoTest.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-#include "ChronoTest.h"
-#include <chrono>
-#include <thread>
-#include <cmath>
-
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ChronoTest, "bits" );
-CPPUNIT_TEST_SUITE_REGISTRATION( ChronoTest );
-
-void ChronoTest::setUp() {
-}
-
-void ChronoTest::tearDown() {
-}
-
-void ChronoTest::testChrono1() {
-	std::chrono::measure_duration tmp;
-	tmp.start();
-	tmp.end();
-
-	std::cout << tmp.duration() << std::endl;
-
-	auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(tmp.duration());
-	std::cout << elapsed << std::endl;
-}
-
-void ChronoTest::testChrono2() {
-	std::chrono::measurements meas;
-	meas.start("global", std::chrono::measurements::Type::OVERALL);
-
-		std::chrono::measurements::start("init", std::chrono::measurements::Type::INIT);
-			std::this_thread::sleep_for(std::chrono::milliseconds(100));
-		std::chrono::measurements::end();
-
-		std::chrono::measurements::start("main", std::chrono::measurements::Type::MAIN);
-			std::this_thread::sleep_for(std::chrono::milliseconds(20));
-			std::chrono::measurements::start("aux", std::chrono::measurements::Type::AUXILIARY);
-				std::this_thread::sleep_for(std::chrono::milliseconds(40));
-			std::chrono::measurements::end();
-			std::this_thread::sleep_for(std::chrono::milliseconds(80));
-			std::chrono::measurements::start("aux", std::chrono::measurements::Type::AUXILIARY);
-				std::this_thread::sleep_for(std::chrono::milliseconds(40));
-			std::chrono::measurements::end();
-			std::this_thread::sleep_for(std::chrono::milliseconds(80));
-		std::chrono::measurements::end();
-
-		std::chrono::measurements::start("fin", std::chrono::measurements::Type::FINALIZE);
-			std::this_thread::sleep_for(std::chrono::milliseconds(30));
-			std::chrono::measurements::start("aux", std::chrono::measurements::Type::AUXILIARY);
-				std::this_thread::sleep_for(std::chrono::milliseconds(40));
-			std::chrono::measurements::end();
-			std::this_thread::sleep_for(std::chrono::milliseconds(80));
-		std::chrono::measurements::end();
-	std::chrono::measurements::end();
-
-	std::cout << "Default print" << std::endl << std::chrono::measurements::results() << std::endl;
-	auto sum1 = std::get<3>(std::chrono::measurements::results()[1]) + std::get<3>(std::chrono::measurements::results()[2]) + std::get<3>(std::chrono::measurements::results()[3]);
-	auto exp1 = std::get<2>(std::chrono::measurements::results()[3]);
-
-	CPPUNIT_ASSERT(std::abs(sum1.count() - exp1.count()) < 2000);
-
-	auto sum2 = std::get<3>(std::chrono::measurements::results()[0]) + std::get<3>(std::chrono::measurements::results()[1]) + std::get<3>(std::chrono::measurements::results()[2]) + std::get<3>(std::chrono::measurements::results()[3]) + std::get<3>(std::chrono::measurements::results()[4]) + std::get<3>(std::chrono::measurements::results()[5]);
-	auto exp2 = std::get<2>(std::chrono::measurements::results()[6]);
-
-	CPPUNIT_ASSERT(std::abs(sum2.count() - exp2.count()) < 2000);
-
-	std::cout << "Tree print" << std::endl << std::chrono::measurements::Format::TREE << std::chrono::measurements::results() << std::endl;
-	std::cout << "Tree print none" << std::endl << std::chrono::measurements::Format::TREE << std::chrono::measurements::Filter::NONE << std::chrono::measurements::results() << std::endl;
-	std::cout << "Tree print all - main" << std::endl << std::chrono::measurements::Format::TREE << std::chrono::measurements::Filter::ALL << std::chrono::measurements::Filter::NO_MAIN << std::chrono::measurements::results() << std::endl;
-	std::cout << "Tree print all - overall" << std::endl << std::chrono::measurements::Format::TREE << std::chrono::measurements::Filter::ALL << std::chrono::measurements::Filter::NO_OVERALL << std::chrono::measurements::results() << std::endl;
-	std::cout << "Tree print all - overall, main" << std::endl << std::chrono::measurements::Format::TREE << std::chrono::measurements::Filter::ALL << std::chrono::measurements::Filter::NO_OVERALL << std::chrono::measurements::Filter::NO_MAIN << std::chrono::measurements::results() << std::endl;
-	std::cout << "Tree print all - overall, main, finalize" << std::endl << std::chrono::measurements::Format::TREE << std::chrono::measurements::Filter::ALL << std::chrono::measurements::Filter::NO_OVERALL << std::chrono::measurements::Filter::NO_MAIN << std::chrono::measurements::Filter::NO_FINALIZE << std::chrono::measurements::results() << std::endl;
-	std::cout << "Tree print none + overall" << std::endl << std::chrono::measurements::Format::TREE << std::chrono::measurements::Filter::NONE << std::chrono::measurements::Filter::OVERALL << std::chrono::measurements::results() << std::endl;
-}
-
diff --git a/alib2std/test-src/extensions/ChronoTest.h b/alib2std/test-src/extensions/ChronoTest.h
deleted file mode 100644
index 6f1d4b6151..0000000000
--- a/alib2std/test-src/extensions/ChronoTest.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef CHRONO_TEST_H_
-#define CHRONO_TEST_H_
-
-#include <cppunit/extensions/HelperMacros.h>
-
-class ChronoTest : public CppUnit::TestFixture
-{
-  CPPUNIT_TEST_SUITE( ChronoTest );
-  CPPUNIT_TEST( testChrono1 );
-  CPPUNIT_TEST( testChrono2 );
-  CPPUNIT_TEST_SUITE_END();
-
-public:
-  void setUp();
-  void tearDown();
-
-  void testChrono1();
-  void testChrono2();
-};
-
-#endif  // CHRONO_TEST_H_
-- 
GitLab