summaryrefslogtreecommitdiff
path: root/tools/slang-test/slang-test-main.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-09-23 15:38:25 -0400
committerGitHub <noreply@github.com>2019-09-23 15:38:25 -0400
commit05af41d21d74d24871507e6f8f50574ea08c48a2 (patch)
tree3197b021ed71c40f6035fdfa7d450b4b3b945422 /tools/slang-test/slang-test-main.cpp
parentede0792fd9b4c7bc5c2653092ba1d492e67ca190 (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 'tools/slang-test/slang-test-main.cpp')
-rw-r--r--tools/slang-test/slang-test-main.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp
index a2d24a54f..e1309d01f 100644
--- a/tools/slang-test/slang-test-main.cpp
+++ b/tools/slang-test/slang-test-main.cpp
@@ -1914,6 +1914,65 @@ static void _addRenderTestOptions(const Options& options, CommandLine& ioCmdLine
}
}
+static SlangResult _extractProfileTime(const UnownedStringSlice& text, double& timeOut)
+{
+ // Need to find the profile figure..
+ LineParser parser(text);
+
+ const auto lineStart = UnownedStringSlice::fromLiteral("profile-time=");
+ for (auto line : parser)
+ {
+ if (line.startsWith(lineStart))
+ {
+ UnownedStringSlice remaining(line.begin() + lineStart.size(), line.end());
+ remaining.trim();
+
+ timeOut = StringToDouble(String(remaining));
+ return SLANG_OK;
+ }
+ }
+
+ return SLANG_FAIL;
+}
+
+TestResult runPerformanceProfile(TestContext* context, TestInput& input)
+{
+ auto outputStem = input.outputStem;
+
+ CommandLine cmdLine;
+
+ cmdLine.setExecutablePath(Path::combine(context->options.binDir, String("render-test") + ProcessUtil::getExecutableSuffix()));
+
+ cmdLine.addArg(input.filePath);
+ cmdLine.addArg("-performance-profile");
+
+ _addRenderTestOptions(context->options, cmdLine);
+
+ for (auto arg : input.testOptions->args)
+ {
+ cmdLine.addArg(arg);
+ }
+
+ ExecuteResult exeRes;
+ TEST_RETURN_ON_DONE(spawnAndWait(context, outputStem, input.spawnType, cmdLine, exeRes));
+ if (context->isCollectingRequirements())
+ {
+ return TestResult::Pass;
+ }
+
+ auto actualOutput = getOutput(exeRes);
+
+ double time;
+ if (SLANG_FAILED(_extractProfileTime(actualOutput.getUnownedSlice(), time)))
+ {
+ return TestResult::Fail;
+ }
+
+ context->reporter->addExecutionTime(time);
+
+ return TestResult::Pass;
+}
+
TestResult runComputeComparisonImpl(TestContext* context, TestInput& input, const char *const* langOpts, size_t numLangOpts)
{
// TODO: delete any existing files at the output path(s) to avoid stale outputs leading to a false pass
@@ -2342,6 +2401,7 @@ static const TestCommandInfo s_testCommandInfos[] =
{ "CPP_COMPILER_EXECUTE", &runCPPCompilerExecute},
{ "CPP_COMPILER_SHARED_LIBRARY", &runCPPCompilerSharedLibrary},
{ "CPP_COMPILER_COMPILE", &runCPPCompilerCompile},
+ { "PERFORMANCE_PROFILE", &runPerformanceProfile},
};
TestResult runTest(