Add timer to print how long the generation took

This commit is contained in:
Thraix
2018-06-10 16:51:44 +02:00
parent f77d3e8a3d
commit 73503f6f48
4 changed files with 32 additions and 2 deletions
+1 -1
View File
@@ -31,6 +31,6 @@ $(OBJPATH)/IncludeDeps.o : src/IncludeDeps.cpp src/IncludeDeps.h
$(OBJPATH)/Makefile.o : src/Makefile.cpp src/Common.h src/IncludeDeps.h src/Makefile.h src/ConfigFile.h
$(info -[75%]- $<)
$(CC) $(CFLAGS) -o $@ $<
$(OBJPATH)/main.o : src/main.cpp src/Common.h src/ConfigFile.h src/IncludeDeps.h src/Makefile.h
$(OBJPATH)/main.o : src/main.cpp src/Common.h src/ConfigFile.h src/IncludeDeps.h src/Makefile.h src/Timer.h
$(info -[100%]- $<)
$(CC) $(CFLAGS) -o $@ $<
+4 -1
View File
@@ -7,9 +7,12 @@
#define STRINGIFY(x) #x
#define STR(x) STRINGIFY(x)
// Major changes, probably not be backwards compatible
#define MAKEGEN_VERSION_MAJOR 1
// Release , should be backwards compatible with any minor version
#define MAKEGEN_VERSION_RELEASE 0
#define MAKEGEN_VERSION_MINOR 4
// Minor changes, should be compatible with any other minor version with same major and release.
#define MAKEGEN_VERSION_MINOR 5
#define MAKEGEN_VERSION ("v" STR(MAKEGEN_VERSION_MAJOR) "." STR(MAKEGEN_VERSION_RELEASE) "." STR(MAKEGEN_VERSION_MINOR))
const static unsigned int FLAG_HELP = BIT(0);
+23
View File
@@ -0,0 +1,23 @@
#pragma once
#include <chrono>
class Timer
{
private:
std::chrono::time_point<std::chrono::high_resolution_clock> m_start;
public:
Timer(){
Reset();
}
void Reset()
{
m_start = std::chrono::high_resolution_clock::now();
}
float Elapsed()
{
return std::chrono::duration_cast<std::chrono::duration<float,std::milli>>(std::chrono::high_resolution_clock::now() - m_start).count() / 1000.0f;
}
};
+4
View File
@@ -4,10 +4,12 @@
#include <vector>
#include <map>
#include <fstream>
#include <cmath>
#include "Common.h"
#include "IncludeDeps.h"
#include "ConfigFile.h"
#include "Makefile.h"
#include "Timer.h"
void GenMakefile()
{
@@ -70,7 +72,9 @@ int main(int argc, char** argv)
return 0;
}
LOG_INFO("Generating Makefile...");
Timer timer;
GenMakefile();
LOG_INFO("Took ", round(timer.Elapsed()*1000.0)/1000.0,"s");
LOG_INFO("Running Makefile...");
for(int i = 1;i<argc;i++)
{