⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 analyzer_clusters.cpp

📁 clustering for ns-2 simulation
💻 CPP
字号:
#include "analyzer_clusters.h"void analyze_clusters(string resultFile, 					  colorsLayer & results, 					  map<string, int> & numNodes){	// Legge simulazione per simulazione.	// Ad ogni simulazione legge i dati di un layer restituendo	// la somma dei 10 valori di dump e la conta dei nodi che hanno	// un tempo di esecuzione diverso da 0.	// Infine vengono registrati i valori totali di bytes e messaggi	// trasmessi.		results.clear();	numNodes.clear();	string topology, stack, line, currentLayer, color, s_tmp;	vector<string> layers;	int n, tmp, nodes;	unsigned int l;			map<string, int> totalNodes;		// Apre il file di dump in lettura.	istream * inFile;	if (use_zipped)		inFile = new igzstream((resultFile + ".gz").c_str());	else		inFile = new ifstream((resultFile).c_str());			while (*inFile >> topology >> stack) {		// cout << "( " << topology << " ) - [" << stack << "]" << endl;		cout << ".";		cout.flush();				extractLayers(stack, layers);				for (l = 0; l < layers.size(); l++) {						*inFile >> currentLayer >> nodes;						// cout << "\t" << layers[l] << ":" << endl;									// Salta i dati relativi ai bytes dei nodi 			for (n = 0; n <= nodes + 1; n++)				getline(*inFile, line, '\n');						string cl = layers[0];			for (unsigned int ll = 1; ll <= l; ll++)				cl += "-" + layers[ll];			numNodes[cl] = nodes;						//			// Skip rest of layer.			//			if (currentLayer == "LEADER") {				// Skip Join row				getline(*inFile, line, '\n');				getline(*inFile, line, '\n');			}			if ((currentLayer == "CLUSTERING") ||				(currentLayer == "RAJARAMAN")) {				// Skip colors.				*inFile >> tmp;				getline(*inFile, line, '\n');				for (int t = 0; t < tmp; t++) {					getline(*inFile, line, '\n');					istringstream inRow(line);					getline(inRow, color, ' ');					int count = 0;					while (getline(inRow, s_tmp, ' '))						count++;										results[cl][color] += count;										// cout << "Color " << color << "(" << cl << ") " << count << endl;										totalNodes[cl] += count;										// cout << "\t\t" << color << ": " << count << endl;				}			}			if (currentLayer == "RAJARAMAN") {				getline(*inFile, line, '\n');			}			if ((currentLayer == "BACKBONE") ||				(currentLayer == "SHIVA") ||				(currentLayer == "CONNECTOR")) {								// Skip colors.				*inFile >> tmp;				getline(*inFile, line, '\n');				for (int t = 0; t < tmp; t++) {					getline(*inFile, line, '\n');					istringstream inRow(line);					getline(inRow, color, ' ');					int count = 0;					while (getline(inRow, s_tmp, ' '))						count++;										results[cl][color] += count;										// cout << "Color " << color << "(" << cl << ") " << count << endl;										totalNodes[cl] += count;					// cout << "\t\t" << color << ": " << count << endl;				}								// Skip backbone.				*inFile >> tmp;				for (int t = 0; t < (tmp + 1); t++)					getline(*inFile, line, '\n');			}			if ((currentLayer == "SHIVA") ||				(currentLayer == "CONNECTOR")) {								getline(*inFile, line, '\n');			}		}	}		// La media finale dei valori si ottiene per layer dividendo	// la somma dei valori per lo stesso layer per il conteggio dei	// nodi che hanno fatto qualcosa in quel layer.		for (colorsLayer::iterator l = results.begin(); l != results.end(); l++)		for (Colors::iterator c = (l->second).begin(); c != (l->second).end(); c++)			c->second = (c->second) / totalNodes[l->first] * 100.0;		cout << endl;		delete(inFile);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -