[PATCH] D37421: [XRay] [test-suite] Add LNT support to retref-bench benchmarks.
Eizan Miyamoto via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 3 04:07:51 PDT 2017
eizan created this revision.
Herald added a subscriber: mgorny.
This might be quite a nasty hack, so I'd like to solicit some feedback
on what the best course to take with it is. I've symlinked the benchmark lib
and XRay microbenchmark sources into LNTBased/XRay. When the test is run, cmake
is invoked and the retref-bench binary is built. When it is run, its output is
parsed and the appropriate TestSamples objects are returned.
This is to accomplish a TODO item in https://reviews.llvm.org/D32272#794759 :
"In the future teach LNT to understand the Google Benchmark output."
https://reviews.llvm.org/D37421
Files:
LNTBased/XRay/CMakeLists.txt
LNTBased/XRay/TestModule
LNTBased/XRay/XRay
LNTBased/XRay/benchmark-1.2.0
Index: LNTBased/XRay/benchmark-1.2.0
===================================================================
--- /dev/null
+++ LNTBased/XRay/benchmark-1.2.0
@@ -0,0 +1 @@
+../../MicroBenchmarks/libs/benchmark-1.2.0/
\ No newline at end of file
Index: LNTBased/XRay/XRay
===================================================================
--- /dev/null
+++ LNTBased/XRay/XRay
@@ -0,0 +1 @@
+../../MicroBenchmarks/XRay/
\ No newline at end of file
Index: LNTBased/XRay/TestModule
===================================================================
--- /dev/null
+++ LNTBased/XRay/TestModule
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+# -*- Python -*-
+
+import csv
+import os
+import StringIO
+import subprocess
+
+from lnt.tests import nt
+from lnt.testing import TestSamples, PASS, FAIL, XFAIL
+
+class Simple(nt.TestModule):
+ def execute_test(self, options, make_variables, config):
+ # build benchmark binary in obj dir
+ rc = subprocess.Popen(
+ ['cmake', options['SRCROOT']],
+ cwd=options['OBJROOT'],
+ env=os.environ.update({
+ 'CXX': options['CXX'],
+ 'CXXFLAGS': options['CXXFLAGS'],
+ 'CC': options['CC'],
+ 'CFLAGS': options['CFLAGS']})).wait()
+ if rc != 0:
+ return TestSamples('nts.LNT/XRay/retref-bench.compile.status', [FAIL])
+
+ rc = subprocess.Popen(
+ ['make', '-j{}'.format(options['BUILD_THREADS'])],
+ cwd=options['OBJROOT']).wait()
+ if rc != 0:
+ return TestSamples('nts.LNT/XRay/retref-bench.compile.status', [FAIL])
+
+ # run benchmark binary and parse output
+ p = subprocess.Popen(
+ ['{}/{}'.format(options['OBJROOT'], 'retref-bench'),
+ '--benchmark_format=csv', '--benchmark_repetitions=10',
+ '--benchmark_report_aggregates_only=true'],
+ cwd=options['OBJROOT'],
+ env=os.environ.update({
+ 'XRAY_OPTIONS': 'patch_premain=false xray_naive_log=false'}),
+ stdout=subprocess.PIPE)
+ bm_output = p.communicate()
+ if p.returncode != 0:
+ return TestSamples('nts.LNT/XRay/retref-bench.exec.status', [FAIL])
+
+ csv_lines = csv.reader(StringIO.StringIO(bm_output[0]))
+ results = []
+ for line in csv_lines:
+ if line[0] == "name":
+ continue
+ results.append(
+ TestSamples('nts.LNT/XRay/retref-bench.{}.exec'.format(line[0]),
+ [float(line[3])]))
+ return results
+
+test_class = Simple
+
+if __name__ == '__main__':
+ test_class().main()
Index: LNTBased/XRay/CMakeLists.txt
===================================================================
--- /dev/null
+++ LNTBased/XRay/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.7)
+
+include(CheckCXXCompilerFlag)
+check_cxx_compiler_flag(-fxray-instrument COMPILER_HAS_FXRAY_INSTRUMENT)
+
+set(ARCH x86)
+
+if("${ARCH}" STREQUAL "x86" AND "${COMPILER_HAS_FXRAY_INSTRUMENT}")
+ add_subdirectory(benchmark-1.2.0)
+
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--gc-sections -fxray-instrument")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fxray-instrument")
+ add_executable(retref-bench XRay/retref-bench.cc)
+ target_link_libraries(retref-bench benchmark)
+endif()
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37421.113683.patch
Type: text/x-patch
Size: 3374 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170903/1323f733/attachment.bin>
More information about the llvm-commits
mailing list