//===-- Timer.cpp - Interval Timing Support -------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
//
// Interval Timing implementation.
//
#include "Support/Timer.h"
#include "Support/CommandLine.h"
-
#include "Config/sys/resource.h"
#include "Config/sys/time.h"
#include "Config/unistd.h"
#include "Config/malloc.h"
-#include "Config/stdio.h"
#include <iostream>
#include <algorithm>
#include <functional>
#include <fstream>
+#include <map>
+using namespace llvm;
+
+// GetLibSupportInfoOutputFile - Return a file stream to print our output on...
+namespace llvm { extern std::ostream *GetLibSupportInfoOutputFile(); }
// getLibSupportInfoOutputFilename - This ugly hack is brought to you courtesy
// of constructor/destructor ordering being unspecified by C++. Basically the
gettimeofday(&T, 0);
if (!Start) {
- MemUsed = getMemUsage();
if (getrusage(RUSAGE_SELF, &RU))
perror("getrusage call failed: -time-passes info incorrect!");
+ MemUsed = getMemUsage();
}
TimeRecord Result;
(*I)->PeakMem = std::max((*I)->PeakMem, MemUsed-(*I)->PeakMemBase);
}
+//===----------------------------------------------------------------------===//
+// NamedRegionTimer Implementation
+//===----------------------------------------------------------------------===//
+
+static Timer &getNamedRegionTimer(const std::string &Name) {
+ static std::map<std::string, Timer> NamedTimers;
+
+ std::map<std::string, Timer>::iterator I = NamedTimers.lower_bound(Name);
+ if (I != NamedTimers.end() && I->first == Name)
+ return I->second;
+
+ return NamedTimers.insert(I, std::make_pair(Name, Timer(Name)))->second;
+}
+
+NamedRegionTimer::NamedRegionTimer(const std::string &Name)
+ : TimeRegion(getNamedRegionTimer(Name)) {}
+
//===----------------------------------------------------------------------===//
// TimerGroup Implementation
}
// GetLibSupportInfoOutputFile - Return a file stream to print our output on...
-std::ostream *GetLibSupportInfoOutputFile() {
+std::ostream *
+llvm::GetLibSupportInfoOutputFile() {
std::string &LibSupportInfoOutputFilename = getLibSupportInfoOutputFilename();
if (LibSupportInfoOutputFilename.empty())
return &std::cerr;
DefaultTimerGroup = 0;
}
}
+