summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--slang.h5
-rw-r--r--source/slang/slang-compiler.cpp6
-rwxr-xr-xsource/slang/slang-compiler.h8
3 files changed, 18 insertions, 1 deletions
diff --git a/slang.h b/slang.h
index 9872180fb..1b8c0c8a4 100644
--- a/slang.h
+++ b/slang.h
@@ -3305,6 +3305,11 @@ namespace slang
@return The compiler that is used for the transition. Returns SLANG_PASS_THROUGH_NONE it is not defined
*/
virtual SLANG_NO_THROW SlangPassThrough SLANG_MCALL getDownstreamCompilerForTransition(SlangCompileTarget source, SlangCompileTarget target) = 0;
+
+ /** Get the time in seconds spent in the downstream compiler.
+ @return The time spent in the downstream compiler in the current global session.
+ */
+ virtual SLANG_NO_THROW double SLANG_MCALL getDownstreamCompilerElapsedTime() = 0;
};
#define SLANG_UUID_IGlobalSession IGlobalSession::getTypeGuid()
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp
index 0e2f339a9..65a18104e 100644
--- a/source/slang/slang-compiler.cpp
+++ b/source/slang/slang-compiler.cpp
@@ -1365,8 +1365,12 @@ namespace Slang
// Compile
RefPtr<DownstreamCompileResult> downstreamCompileResult;
+ auto downstreamStartTime = std::chrono::high_resolution_clock::now();
SLANG_RETURN_ON_FAIL(compiler->compile(options, downstreamCompileResult));
-
+ auto downstreamElapsedTime =
+ (std::chrono::high_resolution_clock::now() - downstreamStartTime).count() * 0.000000001;
+ slangRequest->getSession()->addDownstreamCompileTime(downstreamElapsedTime);
+
const auto& diagnostics = downstreamCompileResult->getDiagnostics();
if (diagnostics.diagnostics.getCount())
diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h
index 9ae414424..a97ec54d8 100755
--- a/source/slang/slang-compiler.h
+++ b/source/slang/slang-compiler.h
@@ -2602,6 +2602,10 @@ namespace Slang
SLANG_NO_THROW void SLANG_MCALL setDownstreamCompilerForTransition(SlangCompileTarget source, SlangCompileTarget target, SlangPassThrough compiler) override;
SLANG_NO_THROW SlangPassThrough SLANG_MCALL getDownstreamCompilerForTransition(SlangCompileTarget source, SlangCompileTarget target) override;
+ SLANG_NO_THROW double SLANG_MCALL getDownstreamCompilerElapsedTime() override
+ {
+ return m_downstreamCompileTime;
+ }
/// Get the downstream compiler for a transition
DownstreamCompiler* getDownstreamCompiler(CodeGenTarget source, CodeGenTarget target);
@@ -2673,6 +2677,8 @@ namespace Slang
String const& source);
~Session();
+ void addDownstreamCompileTime(double time) { m_downstreamCompileTime += time; }
+
ComPtr<ISlangSharedLibraryLoader> m_sharedLibraryLoader; ///< The shared library loader (never null)
int m_downstreamCompilerInitialized = 0;
@@ -2698,6 +2704,8 @@ namespace Slang
// Describes a conversion from one code gen target (source) to another (target)
CodeGenTransitionMap m_codeGenTransitionMap;
+
+ double m_downstreamCompileTime = 0.0;
};