diff options
| author | Yong He <yonghe@outlook.com> | 2022-09-13 13:11:48 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-13 13:11:48 -0700 |
| commit | f216b77752b9e4aea52882b2110ceb1cc64a2171 (patch) | |
| tree | fbb33485b7260bc0f89b406e1be6fb8196f94196 /source/slang/slang-api.cpp | |
| parent | 9f3e83cf0d664c87a618edf08d834829178030e6 (diff) | |
Deduplicate AST type nodes and cache lookup operations. (#2397)
* wip: dedup AST type nodes and cache lookup.
* Fix.
* Remove profiling.
* Fixes.
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-api.cpp')
| -rw-r--r-- | source/slang/slang-api.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/source/slang/slang-api.cpp b/source/slang/slang-api.cpp index a3b1e5409..45c583060 100644 --- a/source/slang/slang-api.cpp +++ b/source/slang/slang-api.cpp @@ -98,11 +98,19 @@ SLANG_API SlangResult slang_createGlobalSession( { Slang::String cacheFilename; uint64_t dllTimestamp = 0; +#define SLANG_PROFILE_STDLIB_COMPILE 0 +#if SLANG_PROFILE_STDLIB_COMPILE + auto startTime = std::chrono::high_resolution_clock::now(); +#else if (tryLoadStdLibFromCache(globalSession, cacheFilename, dllTimestamp) != SLANG_OK) +#endif { // Compile std lib from embeded source. SLANG_RETURN_ON_FAIL(globalSession->compileStdLib(0)); - +#if SLANG_PROFILE_STDLIB_COMPILE + auto timeElapsed = std::chrono::high_resolution_clock::now() - startTime; + printf("stdlib compilation time: %.1fms\n", timeElapsed.count() / 1000000.0); +#endif // Store the compiled stdlib to cache file. trySaveStdLibToCache(globalSession, cacheFilename, dllTimestamp); } |
