From 99bc31fdd6fd9a6cbce6afd5fa9b52fb47873f61 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 10 May 2023 14:10:53 -0700 Subject: Add slangc options for reporting downstream compile time. (#2878) * Add slangc options for reporting downstream compile time. * Update doc. --------- Co-authored-by: Yong He --- source/slang/slang.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'source/slang/slang.cpp') diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index f2598786f..ead1e338f 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -4806,6 +4806,11 @@ void EndToEndCompileRequest::setPassThrough(SlangPassThrough inPassThrough) m_passThrough = PassThroughMode(inPassThrough); } +void EndToEndCompileRequest::setReportDownstreamTime(bool value) +{ + m_reportDownstreamCompileTime = value; +} + void EndToEndCompileRequest::setDiagnosticCallback(SlangDiagnosticCallback callback, void const* userData) { ComPtr writer(new CallbackWriter(callback, userData, WriterFlag::IsConsole)); @@ -5112,7 +5117,11 @@ SlangResult EndToEndCompileRequest::setTypeNameForEntryPointExistentialTypeParam SlangResult EndToEndCompileRequest::EndToEndCompileRequest::compile() { SlangResult res = SLANG_FAIL; - + double downstreamStartTime = 0.0; + if (m_reportDownstreamCompileTime) + { + downstreamStartTime = getSession()->getDownstreamCompilerElapsedTime(); + } #if !defined(SLANG_DEBUG_INTERNAL_ERROR) // By default we'd like to catch as many internal errors as possible, // and report them to the user nicely (rather than just crash their @@ -5160,6 +5169,14 @@ SlangResult EndToEndCompileRequest::EndToEndCompileRequest::compile() } #endif + if (m_reportDownstreamCompileTime) + { + double downstreamTime = getSession()->getDownstreamCompilerElapsedTime() - downstreamStartTime; + String downstreamTimeStr = String(downstreamTime, "%.2f"); + getSink()->diagnose(SourceLoc(), Diagnostics::downstreamCompileTime, downstreamTimeStr); + + } + // Repro dump handling { if (m_dumpRepro.getLength()) -- cgit v1.2.3