From f88e1299b7715190ce82f3f4473f0d0eeaa2000e Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 23 May 2023 15:19:27 -0700 Subject: Add API for querying total compile time. (#2898) * Add API for querying total compile time. * Optimize. * Remove redundant simplifyIR calls. * Fix. --------- Co-authored-by: Yong He --- source/slang/slang.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source/slang/slang.cpp') diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index ead1e338f..d651f0737 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -2997,6 +2997,8 @@ RefPtr Linkage::loadModule( DiagnosticSink* sink, const LoadedModuleDictionary* additionalLoadedModules) { + CompileTimerRAII recordCompileTime(static_cast(getGlobalSession())); + RefPtr frontEndReq = new FrontEndCompileRequest(this, nullptr, sink); frontEndReq->additionalLoadedModules = additionalLoadedModules; @@ -5118,9 +5120,11 @@ SlangResult EndToEndCompileRequest::EndToEndCompileRequest::compile() { SlangResult res = SLANG_FAIL; double downstreamStartTime = 0.0; + double totalStartTime = 0.0; + if (m_reportDownstreamCompileTime) { - downstreamStartTime = getSession()->getDownstreamCompilerElapsedTime(); + getSession()->getCompilerElapsedTime(&totalStartTime, &downstreamStartTime); } #if !defined(SLANG_DEBUG_INTERNAL_ERROR) // By default we'd like to catch as many internal errors as possible, @@ -5171,7 +5175,10 @@ SlangResult EndToEndCompileRequest::EndToEndCompileRequest::compile() if (m_reportDownstreamCompileTime) { - double downstreamTime = getSession()->getDownstreamCompilerElapsedTime() - downstreamStartTime; + double downstreamEndTime = 0; + double totalEndTime = 0; + getSession()->getCompilerElapsedTime(&totalEndTime, &downstreamEndTime); + double downstreamTime = downstreamEndTime - downstreamStartTime; String downstreamTimeStr = String(downstreamTime, "%.2f"); getSink()->diagnose(SourceLoc(), Diagnostics::downstreamCompileTime, downstreamTimeStr); -- cgit v1.2.3