diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-09-23 15:38:25 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-23 15:38:25 -0400 |
| commit | 05af41d21d74d24871507e6f8f50574ea08c48a2 (patch) | |
| tree | 3197b021ed71c40f6035fdfa7d450b4b3b945422 /source/core | |
| parent | ede0792fd9b4c7bc5c2653092ba1d492e67ca190 (diff) | |
Simple test profiling (#1062)
* First pass support for performance profiling
* Test across all elements
* Fix bug - sourceContents is not used, should use rawSource.
* * Add ability to get prelude from API.
* Allow specifying source language for render-test
* Made it possible to compile a test input file as C++
* Special handling for reflection
* Added C++ impl to performance-profile.slang
* Remove some clang warnings.
* Output profile timings on appveyor and other TC.
* Remove passing around of StdWriters (can use global).
Small comment improvements.
Diffstat (limited to 'source/core')
| -rw-r--r-- | source/core/slang-process-util.h | 4 | ||||
| -rw-r--r-- | source/core/unix/slang-unix-process-util.cpp | 15 | ||||
| -rw-r--r-- | source/core/windows/slang-win-process-util.cpp | 21 |
3 files changed, 40 insertions, 0 deletions
diff --git a/source/core/slang-process-util.h b/source/core/slang-process-util.h index 89e3400a0..5d8c358e8 100644 --- a/source/core/slang-process-util.h +++ b/source/core/slang-process-util.h @@ -91,6 +91,10 @@ struct ProcessUtil /// Append text escaped for using on a command line static void appendCommandLineEscaped(const UnownedStringSlice& slice, StringBuilder& out); + + static uint64_t getClockFrequency(); + + static uint64_t getClockTick(); }; // ----------------------------------------------------------------------- diff --git a/source/core/unix/slang-unix-process-util.cpp b/source/core/unix/slang-unix-process-util.cpp index 400f4f773..ab4366b06 100644 --- a/source/core/unix/slang-unix-process-util.cpp +++ b/source/core/unix/slang-unix-process-util.cpp @@ -15,6 +15,8 @@ #include <sys/wait.h> #include <unistd.h> +#include <time.h> + namespace Slang { @@ -247,4 +249,17 @@ namespace Slang { return SLANG_FAIL; } + +/* static */uint64_t ProcessUtil::getClockFrequency() +{ + return 1000000000; +} + +/* static */uint64_t ProcessUtil::getClockTick() +{ + struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + return now.tv_sec + now.tv_nsec; +} + } // namespace Slang diff --git a/source/core/windows/slang-win-process-util.cpp b/source/core/windows/slang-win-process-util.cpp index ac6468109..3a5a01cb3 100644 --- a/source/core/windows/slang-win-process-util.cpp +++ b/source/core/windows/slang-win-process-util.cpp @@ -344,4 +344,25 @@ static DWORD WINAPI _readerThreadProc(LPVOID threadParam) return SLANG_OK; } +static uint64_t _getClockFrequency() +{ + LARGE_INTEGER timerFrequency; + QueryPerformanceFrequency(&timerFrequency); + return timerFrequency.QuadPart; +} + +static const uint64_t g_frequency = _getClockFrequency(); + +/* static */uint64_t ProcessUtil::getClockFrequency() +{ + return g_frequency; +} + +/* static */uint64_t ProcessUtil::getClockTick() +{ + LARGE_INTEGER counter; + QueryPerformanceCounter(&counter); + return counter.QuadPart; +} + } |
