summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-02-11 00:16:54 -0800
committerGitHub <noreply@github.com>2022-02-11 00:16:54 -0800
commit7d296ba93ff9f01d381dd573160386958457fc18 (patch)
tree8ad1c8d35499aa027714cc17cba17b8e3ac2f14b /source
parent434fd8ec7558614a3b6eef484410dddd62c9cbbd (diff)
Add interface for querying downstream compiler time (#2127)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-compiler.cpp6
-rwxr-xr-xsource/slang/slang-compiler.h8
2 files changed, 13 insertions, 1 deletions
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;
};