xPerformanceAnalysis.cxx 2.47 KB
Newer Older
Baum's avatar
Baum committed
1
// Xerus - A General Purpose Tensor Library
Sebastian Wolf's avatar
Sebastian Wolf committed
2
// Copyright (C) 2014-2016 Benjamin Huber and Sebastian Wolf. 
Baum's avatar
Baum committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// 
// Xerus is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
// 
// Xerus is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// 
// You should have received a copy of the GNU Affero General Public License
// along with Xerus. If not, see <http://www.gnu.org/licenses/>.
//
// For further information on Xerus visit https://libXerus.org 
// or contact us at contact@libXerus.org.

20
21

#include<xerus.h>
22
#include "../../include/xerus/misc/internal.h"
23

24
#include "../../include/xerus/test/test.h"
25
using namespace xerus;
Baum's avatar
Baum committed
26

27
#ifdef XERUS_PERFORMANCE_ANALYSIS
28
	#ifdef XERUS_REPLACE_ALLOCATOR  
29
		static misc::UnitTest perfana("x_PerformanceAnalysis_x", "Analysis", [](){
30
31
32
33
34
35
36
37
38
39
			std::cout << misc::performanceAnalysis::get_analysis();
			LOG(Indices, "A total of " << Index().valueId << " indices were used (in this thread).");
			
			using xma = xerus::misc::AllocatorStorage;
			namespace xm = xerus::misc; 
			LOG(allocator, "");
			size_t totalStorage=0;
			for (size_t i=0; i<xma::NUM_BUCKETS; ++i) {
				if (xm::astore.allocCount[i] == 0 && xm::astore.currAlloc[i] == 0) continue;
				totalStorage += i * xma::BUCKET_SIZE * (size_t)xm::astore.maxAlloc[i];
Benjamin Huber's avatar
Benjamin Huber committed
40
				LOG(allocator, (i+1) * xma::BUCKET_SIZE-1 << " \tx\t " << xm::astore.allocCount[i] << "\tmax: " << xm::astore.maxAlloc[i] << '\t' << xm::astore.currAlloc[i] << '\t' << totalStorage);
41
42
43
44
45
46
			}
			LOG(storageNeeded, totalStorage << " storage used: " << misc::astore.pools.size()*xma::POOL_SIZE);
			LOG(index, sizeof(Index));
			LOG(node, sizeof(TensorNetwork::TensorNode));
			LOG(link, sizeof(TensorNetwork::Link));
			LOG(tn, sizeof(TensorNetwork));
Sebastian Wolf's avatar
Sebastian Wolf committed
47
			LOG(fulltensor, sizeof(Tensor));
Sebastian Wolf's avatar
Sebastian Wolf committed
48
			LOG(Tensor, sizeof(Tensor));
49
50
			LOG(tt, sizeof(TTTensor) << " | " << sizeof(TTOperator));
			LOG(measurement, sizeof(SinglePointMeasurment));
51
		});
52
	#else
53
		static misc::UnitTest perfana("x_PerformanceAnalysis_x", "Analysis", [](){
54
55
			std::cout << misc::performanceAnalysis::get_analysis();
			LOG(Indices, "A total of " << Index().valueId << " indices were used (in this thread).");
56
		});
57
	#endif
58
#endif