From 73503f6f489d55091a0279bb5341275e1100f036 Mon Sep 17 00:00:00 2001 From: Thraix Date: Sun, 10 Jun 2018 16:51:44 +0200 Subject: [PATCH] Add timer to print how long the generation took --- Makefile | 2 +- src/Common.h | 5 ++++- src/Timer.h | 23 +++++++++++++++++++++++ src/main.cpp | 4 ++++ 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 src/Timer.h diff --git a/Makefile b/Makefile index e8e5f20..674ca30 100644 --- a/Makefile +++ b/Makefile @@ -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 $@ $< diff --git a/src/Common.h b/src/Common.h index f2244b1..b047f50 100644 --- a/src/Common.h +++ b/src/Common.h @@ -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); diff --git a/src/Timer.h b/src/Timer.h new file mode 100644 index 0000000..c23022c --- /dev/null +++ b/src/Timer.h @@ -0,0 +1,23 @@ +#pragma once + +#include + +class Timer +{ + private: + std::chrono::time_point m_start; + public: + Timer(){ + Reset(); + } + + void Reset() + { + m_start = std::chrono::high_resolution_clock::now(); + } + + float Elapsed() + { + return std::chrono::duration_cast>(std::chrono::high_resolution_clock::now() - m_start).count() / 1000.0f; + } +}; diff --git a/src/main.cpp b/src/main.cpp index 4b1444a..ecf032f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,10 +4,12 @@ #include #include #include +#include #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