当前位置: 首页>>代码示例>>C++>>正文


C++ Timestamp::getSecondInDay方法代码示例

本文整理汇总了C++中Timestamp::getSecondInDay方法的典型用法代码示例。如果您正苦于以下问题:C++ Timestamp::getSecondInDay方法的具体用法?C++ Timestamp::getSecondInDay怎么用?C++ Timestamp::getSecondInDay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Timestamp的用法示例。


在下文中一共展示了Timestamp::getSecondInDay方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(void) {
  char logFileName[300] = "/home/danconde/coleta/europa.log";
  ResourceData parameters(0.5f, 100000);
  bool answer;
  DataCollector *dtCollector = new DataCollector(logFileName);
  unsigned int i, count;
  UsageData *testUsageData;
  
  setValidResourceDataThreshold(0.9f);
  setPredictionHours(6);
  
  cout << "timestamp\tp_cpu\tp_mem\tanswer\tpcs\tvcs\tcoff" << endl;
  // pcs = predicted cpu satisfability
  // vcs = verified cpu satisfability
  
  UsagePredictor *up = new UsagePredictor(new KMeansClusteringAlgorithm(), dtCollector);
  vector<UsageData*> *usageDatas = dtCollector->getUnclassifiedData();
  
  for (unsigned int k = 0; k < usageDatas->size(); k += 3) {
     testUsageData = usageDatas->at(k);
     if (testUsageData->isValid()) {
	 for (unsigned int j = 6; j < 18; j++) {
	       Timestamp timestamp = Timestamp(testUsageData->getDate().beginningOfSameDay().getRawTime() + j*3600);
	       
	       answer = up->canRunGridApplication(timestamp, parameters, testUsageData);
	       cout << timestamp.formattedPrint() << "\t" << parameters << "\t" << answer << "\t";
	       
	       vector<double> prediction = up->getPrediction(timestamp, CPU_USAGE, getPredictionHours(), testUsageData);
	       count = 0;
	       for (i = 0; i < prediction.size(); i++)
		  if (prediction[i] + parameters.getCpuUsage() <= 1.0f)
		  count++;
	       cout << (static_cast<double>(count) / prediction.size()) * 100 << "%\t";
	       
	       count = 0;
	       for (i = 0; i < prediction.size(); i++) {
		  ResourceData rd = testUsageData->getData()[(timestamp.getSecondInDay()/COLLECT_INTERVAL) + SAMPLES_PER_DAY + i];
		  if (rd.isValid() && (rd.getCpuUsage()  + parameters.getCpuUsage() <= 1.0f))
		     count++;
	       }
	       cout << (static_cast<double>(count) / prediction.size()) * 100 << "%\t";
	       
	       cout << testUsageData->resourceAverage(CPU_USAGE, timestamp.getSecondInDay()/COLLECT_INTERVAL, timestamp.getSecondInDay()/COLLECT_INTERVAL + SAMPLES_PER_DAY) << endl;
	 }
     }
  }
  /* informar qual cluster foi encontrado */
  /* comparar resultado da predicao com o realizado */
  /* pegar o resultado do getPrediction e ver a porcentagem de elementos do vetor de previsao condisseram
     com o realizado */
  
  return 0;
}
开发者ID:felps,项目名称:FTFramework,代码行数:53,代码来源:PredictionTester.cpp


注:本文中的Timestamp::getSecondInDay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。