From 4f3753a7492fd7a79024bef47f77c7ad16f1c17d Mon Sep 17 00:00:00 2001 From: Pavol Vaskovic Date: Sat, 8 Apr 2017 09:13:18 +0200 Subject: [PATCH 01/10] Add support for GYB in benchmarks --- benchmark/CMakeLists.txt | 1 + .../generate_harness/generate_harness.py | 8 + benchmark/single-source/DropLast.swift | 172 ++++++++++++---- benchmark/single-source/DropLast.swift.gyb | 58 ++++++ benchmark/single-source/Prefix.swift | 169 +++++++++++++++ benchmark/single-source/Prefix.swift.gyb | 57 ++++++ benchmark/single-source/Suffix.swift | 193 ++++++++++++++---- benchmark/single-source/Suffix.swift.gyb | 57 ++++++ benchmark/utils/main.swift | 31 +++ .../benchmarks/generate-harness.test-sh | 4 + 10 files changed, 663 insertions(+), 87 deletions(-) create mode 100644 benchmark/single-source/DropLast.swift.gyb create mode 100644 benchmark/single-source/Prefix.swift create mode 100644 benchmark/single-source/Prefix.swift.gyb create mode 100644 benchmark/single-source/Suffix.swift.gyb create mode 100644 validation-test/benchmarks/generate-harness.test-sh diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index 010bf08b79164..75dc4a97cb04a 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -79,6 +79,7 @@ set(SWIFT_BENCH_MODULES single-source/PolymorphicCalls single-source/PopFront single-source/PopFrontGeneric + single-source/Prefix single-source/Prims single-source/ProtocolDispatch single-source/ProtocolDispatch2 diff --git a/benchmark/scripts/generate_harness/generate_harness.py b/benchmark/scripts/generate_harness/generate_harness.py index 527e40e8fd25f..79a5389177764 100755 --- a/benchmark/scripts/generate_harness/generate_harness.py +++ b/benchmark/scripts/generate_harness/generate_harness.py @@ -19,6 +19,7 @@ import glob import os import re +import subprocess import jinja2 @@ -38,6 +39,13 @@ lstrip_blocks=True) if __name__ == '__main__': + # Generate Your Boilerplate single-source + gyb_files = glob.glob(os.path.join(single_source_dir, '*.swift.gyb')) + gyb_script = os.path.realpath(os.path.join(perf_dir, '../utils/gyb')) + for f in gyb_files: + print(f[:-4]) + subprocess.call([gyb_script, '--line-directive', '', '-o', f[:-4], f]) + # CMakeList single-source test_files = glob.glob(os.path.join(single_source_dir, '*.swift')) tests = sorted(os.path.basename(x).split('.')[0] for x in test_files) diff --git a/benchmark/single-source/DropLast.swift b/benchmark/single-source/DropLast.swift index bce532c200d07..29b35ad593dba 100644 --- a/benchmark/single-source/DropLast.swift +++ b/benchmark/single-source/DropLast.swift @@ -10,77 +10,161 @@ // //===----------------------------------------------------------------------===// +//////////////////////////////////////////////////////////////////////////////// +// WARNING: This file is manually generated from .gyb template and should not +// be directly modified. Instead, make changes to Suffix.swift.gyb and run +// scripts/generate_harness/generate_harness.py to regenerate this file. +//////////////////////////////////////////////////////////////////////////////// + import TestsUtils -let reps = 1 let sequenceCount = 4096 let prefixCount = 1024 let dropCount = sequenceCount - prefixCount -let sumCount = prefixCount * (prefixCount-1) / 2 +let sumCount = prefixCount * (prefixCount - 1) / 2 + @inline(never) public func run_DropLastCountableRange(_ N: Int) { - let s = 0 ..< sequenceCount + let s = 0.. - public func makeIterator() -> IndexingIterator> { - return range.makeIterator() - } -} - @inline(never) public func run_DropLastSequence(_ N: Int) { - let s = MySequence(range: 0 ..< sequenceCount) + let s = sequence(first: 0) { $0 < sequenceCount - 1 ? $0 &+ 1 : nil } for _ in 1...20*N { - for _ in 1...reps { - var result = 0 - for element in s.dropLast(dropCount) { - result += element - } - CheckResults(result == sumCount, - "IncorrectResults in DropLastSequence: \(result) != \(sumCount)") + var result = 0 + for element in s.dropLast(dropCount) { + result += element } + CheckResults(result == sumCount, + "IncorrectResults in DropLastSequence: \(result) != \(sumCount)") } } - @inline(never) public func run_DropLastAnySequence(_ N: Int) { - let s = AnySequence(0 ..< sequenceCount) + let s = AnySequence(sequence(first: 0) { $0 < sequenceCount - 1 ? $0 &+ 1 : nil }) for _ in 1...20*N { - for _ in 1...reps { - var result = 0 - for element in s.dropLast(dropCount) { - result += element - } - CheckResults(result == sumCount, - "IncorrectResults in DropLastAnySequence: \(result) != \(sumCount)") + var result = 0 + for element in s.dropLast(dropCount) { + result += element } + CheckResults(result == sumCount, + "IncorrectResults in DropLastAnySequence: \(result) != \(sumCount)") + } +} +@inline(never) +public func run_DropLastAnySeqCntRange(_ N: Int) { + let s = AnySequence(0.. - public func makeIterator() -> IndexingIterator> { - return range.makeIterator() - } -} - @inline(never) public func run_SuffixSequence(_ N: Int) { - let s = MySequence(range: 0 ..< sequenceCount) + let s = sequence(first: 0) { $0 < sequenceCount - 1 ? $0 &+ 1 : nil } for _ in 1...20*N { - for _ in 1...reps { - var result = 0 - for element in s.suffix(suffixCount) { - result += element - } - CheckResults(result == sumCount, - "IncorrectResults in SuffixSequence: \(result) != \(sumCount)") + var result = 0 + for element in s.suffix(suffixCount) { + result += element } + CheckResults(result == sumCount, + "IncorrectResults in SuffixSequence: \(result) != \(sumCount)") } } - @inline(never) public func run_SuffixAnySequence(_ N: Int) { - let s = AnySequence(0 ..< sequenceCount) + let s = AnySequence(sequence(first: 0) { $0 < sequenceCount - 1 ? $0 &+ 1 : nil }) for _ in 1...20*N { - for _ in 1...reps { - var result = 0 - for element in s.suffix(suffixCount) { - result += element - } - CheckResults(result == sumCount, - "IncorrectResults in SuffixAnySequence: \(result) != \(sumCount)") + var result = 0 + for element in s.suffix(suffixCount) { + result += element } + CheckResults(result == sumCount, + "IncorrectResults in SuffixAnySequence: \(result) != \(sumCount)") + } +} +@inline(never) +public func run_SuffixAnySeqCntRange(_ N: Int) { + let s = AnySequence(0.. Date: Sat, 8 Apr 2017 09:20:53 +0200 Subject: [PATCH 02/10] Fixed filename in the comments. --- benchmark/single-source/Prefix.swift.gyb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmark/single-source/Prefix.swift.gyb b/benchmark/single-source/Prefix.swift.gyb index e8afb3148f1a5..6a2d7f900409a 100644 --- a/benchmark/single-source/Prefix.swift.gyb +++ b/benchmark/single-source/Prefix.swift.gyb @@ -1,4 +1,4 @@ -//===--- Suffix.swift ---------------------------------------------------===// +//===--- Prefix.swift -----------------------------------------------------===// // // This source file is part of the Swift.org open source project // @@ -13,7 +13,7 @@ % # Ignore the following warning. This _is_ the correct file to edit. //////////////////////////////////////////////////////////////////////////////// // WARNING: This file is manually generated from .gyb template and should not -// be directly modified. Instead, make changes to Suffix.swift.gyb and run +// be directly modified. Instead, make changes to Prefix.swift.gyb and run // scripts/generate_harness/generate_harness.py to regenerate this file. //////////////////////////////////////////////////////////////////////////////// From 11065bec81f993ce90fcdf24d4a21bd2d66f51c5 Mon Sep 17 00:00:00 2001 From: Pavol Vaskovic Date: Sat, 8 Apr 2017 09:22:56 +0200 Subject: [PATCH 03/10] Fixed more filenames in the comments. --- benchmark/single-source/DropLast.swift | 2 +- benchmark/single-source/DropLast.swift.gyb | 2 +- benchmark/single-source/Prefix.swift | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/benchmark/single-source/DropLast.swift b/benchmark/single-source/DropLast.swift index 29b35ad593dba..404a28c3d88ac 100644 --- a/benchmark/single-source/DropLast.swift +++ b/benchmark/single-source/DropLast.swift @@ -12,7 +12,7 @@ //////////////////////////////////////////////////////////////////////////////// // WARNING: This file is manually generated from .gyb template and should not -// be directly modified. Instead, make changes to Suffix.swift.gyb and run +// be directly modified. Instead, make changes to DropLast.swift.gyb and run // scripts/generate_harness/generate_harness.py to regenerate this file. //////////////////////////////////////////////////////////////////////////////// diff --git a/benchmark/single-source/DropLast.swift.gyb b/benchmark/single-source/DropLast.swift.gyb index 02e89aa95cee6..3383b27759e9e 100644 --- a/benchmark/single-source/DropLast.swift.gyb +++ b/benchmark/single-source/DropLast.swift.gyb @@ -13,7 +13,7 @@ % # Ignore the following warning. This _is_ the correct file to edit. //////////////////////////////////////////////////////////////////////////////// // WARNING: This file is manually generated from .gyb template and should not -// be directly modified. Instead, make changes to Suffix.swift.gyb and run +// be directly modified. Instead, make changes to DropLast.swift.gyb and run // scripts/generate_harness/generate_harness.py to regenerate this file. //////////////////////////////////////////////////////////////////////////////// diff --git a/benchmark/single-source/Prefix.swift b/benchmark/single-source/Prefix.swift index 698426e73fc77..44547a64de8d2 100644 --- a/benchmark/single-source/Prefix.swift +++ b/benchmark/single-source/Prefix.swift @@ -1,4 +1,4 @@ -//===--- Suffix.swift ---------------------------------------------------===// +//===--- Prefix.swift -----------------------------------------------------===// // // This source file is part of the Swift.org open source project // @@ -12,7 +12,7 @@ //////////////////////////////////////////////////////////////////////////////// // WARNING: This file is manually generated from .gyb template and should not -// be directly modified. Instead, make changes to Suffix.swift.gyb and run +// be directly modified. Instead, make changes to Prefix.swift.gyb and run // scripts/generate_harness/generate_harness.py to regenerate this file. //////////////////////////////////////////////////////////////////////////////// From 7c103d80c6876427a107a7b0fb0392402a55589f Mon Sep 17 00:00:00 2001 From: Pavol Vaskovic Date: Tue, 11 Apr 2017 00:47:34 +0200 Subject: [PATCH 04/10] Validate that benchmark commits contain freshly generated test harness --- .../generate_harness/generate_harness.py | 68 +++++++++++-------- .../generate_harness/test_generate_harness.sh | 14 ++++ .../benchmarks/generate-harness.test-sh | 9 +-- 3 files changed, 59 insertions(+), 32 deletions(-) create mode 100755 benchmark/scripts/generate_harness/test_generate_harness.sh diff --git a/benchmark/scripts/generate_harness/generate_harness.py b/benchmark/scripts/generate_harness/generate_harness.py index 79a5389177764..0b28ca31c6569 100755 --- a/benchmark/scripts/generate_harness/generate_harness.py +++ b/benchmark/scripts/generate_harness/generate_harness.py @@ -12,25 +12,31 @@ # # ===---------------------------------------------------------------------===// -# Generate CMakeLists.txt and utils/main.swift from templates. +# Generate boilerplate, CMakeLists.txt and utils/main.swift from templates. from __future__ import print_function -import glob +import argparse +import jinja2 import os import re import subprocess -import jinja2 - script_dir = os.path.dirname(os.path.realpath(__file__)) perf_dir = os.path.realpath(os.path.join(script_dir, '../..')) +gyb_script = os.path.realpath(os.path.join(perf_dir, '../utils/gyb')) single_source_dir = os.path.join(perf_dir, 'single-source') multi_source_dir = os.path.join(perf_dir, 'multi-source') +parser = argparse.ArgumentParser() +parser.add_argument("--output-dir", + help="Output directory (for validation test)", + default=perf_dir) +args = parser.parse_args() +output_dir = args.output_dir template_map = { - 'CMakeLists.txt_template': os.path.join(perf_dir, 'CMakeLists.txt'), - 'main.swift_template': os.path.join(perf_dir, 'utils/main.swift') + 'CMakeLists.txt_template': os.path.join(output_dir, 'CMakeLists.txt'), + 'main.swift_template': os.path.join(output_dir, 'utils/main.swift') } ignored_run_funcs = ["Ackermann", "Fibonacci"] @@ -38,25 +44,38 @@ template_env = jinja2.Environment(loader=template_loader, trim_blocks=True, lstrip_blocks=True) +def all_files(directory, extension): # matching: [directory]/**/*[extension] + return [ + os.path.join(root, f) + for root, _, files in os.walk(directory) + for f in files if f.endswith(extension) + ] + +def will_write(filename): # ensure path to file exists before writing + print(filename) + output_path = os.path.split(filename)[0] + if not os.path.exists(output_path): os.makedirs(output_path) + if __name__ == '__main__': - # Generate Your Boilerplate single-source - gyb_files = glob.glob(os.path.join(single_source_dir, '*.swift.gyb')) - gyb_script = os.path.realpath(os.path.join(perf_dir, '../utils/gyb')) + # Generate Your Boilerplate + gyb_files = all_files(perf_dir, '.swift.gyb') for f in gyb_files: - print(f[:-4]) - subprocess.call([gyb_script, '--line-directive', '', '-o', f[:-4], f]) + relative_path = os.path.relpath(f[:-4], perf_dir) + out_file = os.path.join(output_dir, relative_path) + will_write(out_file) + subprocess.call([gyb_script, '--line-directive', '', '-o', out_file, f]) # CMakeList single-source - test_files = glob.glob(os.path.join(single_source_dir, '*.swift')) + test_files = all_files(single_source_dir,'.swift') tests = sorted(os.path.basename(x).split('.')[0] for x in test_files) # CMakeList multi-source class MultiSourceBench(object): - def __init__(self, path): self.name = os.path.basename(path) self.files = [x for x in os.listdir(path) if x.endswith('.swift')] + if os.path.isdir(multi_source_dir): multisource_benches = [ MultiSourceBench(os.path.join(multi_source_dir, x)) @@ -75,26 +94,19 @@ def get_run_funcs(filepath): matches = re.findall(r'func run_(.*?)\(', content) return filter(lambda x: x not in ignored_run_funcs, matches) - def find_run_funcs(dirs): - ret_run_funcs = [] - for d in dirs: - for root, _, files in os.walk(d): - for name in filter(lambda x: x.endswith('.swift'), files): - run_funcs = get_run_funcs(os.path.join(root, name)) - ret_run_funcs.extend(run_funcs) - return ret_run_funcs - run_funcs = sorted( - [(x, x) - for x in find_run_funcs([single_source_dir, multi_source_dir])], - key=lambda x: x[0] - ) + def find_run_funcs(): + swift_files = all_files(perf_dir, '.swift') + return [func for f in swift_files for func in get_run_funcs(f)] + + run_funcs = [(f, f) for f in sorted(find_run_funcs())] # Replace originals with files generated from templates for template_file in template_map: template_path = os.path.join(script_dir, template_file) template = template_env.get_template(template_path) - print(template_map[template_file]) - open(template_map[template_file], 'w').write( + out_file = template_map[template_file] + will_write(out_file) + open(out_file, 'w').write( template.render(tests=tests, multisource_benches=multisource_benches, imports=imports, diff --git a/benchmark/scripts/generate_harness/test_generate_harness.sh b/benchmark/scripts/generate_harness/test_generate_harness.sh new file mode 100755 index 0000000000000..ed1bb430e92c3 --- /dev/null +++ b/benchmark/scripts/generate_harness/test_generate_harness.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +SWIFT_SRC_DIR="$1" +BENCHMARK_DIR="${SWIFT_SRC_DIR}/benchmark" +SCRIPT_DIR="${BENCHMARK_DIR}/scripts" +TEMP_DIR="$2" + +"${SCRIPT_DIR}/generate_harness/generate_harness.py" "--output-dir=${TEMP_DIR}" +for f in $(cd "${TEMP_DIR}" && find ./ -type f); do + diff "${TEMP_DIR}/${f}" "${BENCHMARK_DIR}/${f}" + if [[ $? -ne 0 ]]; then + exit 1 + fi +done diff --git a/validation-test/benchmarks/generate-harness.test-sh b/validation-test/benchmarks/generate-harness.test-sh index e7c289644938d..0e77aaf796a86 100644 --- a/validation-test/benchmarks/generate-harness.test-sh +++ b/validation-test/benchmarks/generate-harness.test-sh @@ -1,4 +1,5 @@ -This will just be a shell script along the lines of bug-reducer.test-sh that -will generate the harness/gyb files in a temp directory and make sure that the -diff to what is checked into tree is empty. Then at least we will know if -someone forgets to regenerate the harness or gyb files. +// RUN: rm -rfv %t +// RUN: %swift_src_root/benchmarks/scripts/test_generate_harness.sh %swift_src_root %t +// REQUIRES: OS=macosx +// REQUIRES: asserts +// REQUIRES: CMAKE_GENERATOR=Ninja From 739c3b70a86527f8c6ffc4f4a2d94cd994bcd5b9 Mon Sep 17 00:00:00 2001 From: Pavol Vaskovic Date: Tue, 11 Apr 2017 01:22:43 +0200 Subject: [PATCH 05/10] Add same test variants for DropLast and Prefix as exist on Suffix --- benchmark/single-source/DropLast.swift | 25 +++++++++++++++++++++- benchmark/single-source/DropLast.swift.gyb | 2 +- benchmark/single-source/Prefix.swift | 25 +++++++++++++++++++++- benchmark/single-source/Prefix.swift.gyb | 2 +- benchmark/utils/main.swift | 4 ++++ 5 files changed, 54 insertions(+), 4 deletions(-) diff --git a/benchmark/single-source/DropLast.swift b/benchmark/single-source/DropLast.swift index 404a28c3d88ac..c89d017fd5f92 100644 --- a/benchmark/single-source/DropLast.swift +++ b/benchmark/single-source/DropLast.swift @@ -23,7 +23,6 @@ let prefixCount = 1024 let dropCount = sequenceCount - prefixCount let sumCount = prefixCount * (prefixCount - 1) / 2 - @inline(never) public func run_DropLastCountableRange(_ N: Int) { let s = 0.. Date: Wed, 12 Apr 2017 01:15:02 +0200 Subject: [PATCH 06/10] Performance tests for Sequence methods: DropFirst, DropWhile, PrefixWhile --- benchmark/CMakeLists.txt | 3 + benchmark/single-source/DropFirst.swift | 193 ++++++++++++++++++ benchmark/single-source/DropFirst.swift.gyb | 58 ++++++ benchmark/single-source/DropWhile.swift | 193 ++++++++++++++++++ benchmark/single-source/DropWhile.swift.gyb | 58 ++++++ benchmark/single-source/PrefixWhile.swift | 192 +++++++++++++++++ benchmark/single-source/PrefixWhile.swift.gyb | 57 ++++++ benchmark/utils/main.swift | 45 ++++ 8 files changed, 799 insertions(+) create mode 100644 benchmark/single-source/DropFirst.swift create mode 100644 benchmark/single-source/DropFirst.swift.gyb create mode 100644 benchmark/single-source/DropWhile.swift create mode 100644 benchmark/single-source/DropWhile.swift.gyb create mode 100644 benchmark/single-source/PrefixWhile.swift create mode 100644 benchmark/single-source/PrefixWhile.swift.gyb diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index 75dc4a97cb04a..047a0f5255e12 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -44,7 +44,9 @@ set(SWIFT_BENCH_MODULES single-source/DictionaryLiteral single-source/DictionaryRemove single-source/DictionarySwap + single-source/DropFirst single-source/DropLast + single-source/DropWhile single-source/ErrorHandling single-source/ExistentialPerformance single-source/Fibonacci @@ -80,6 +82,7 @@ set(SWIFT_BENCH_MODULES single-source/PopFront single-source/PopFrontGeneric single-source/Prefix + single-source/PrefixWhile single-source/Prims single-source/ProtocolDispatch single-source/ProtocolDispatch2 diff --git a/benchmark/single-source/DropFirst.swift b/benchmark/single-source/DropFirst.swift new file mode 100644 index 0000000000000..e8ea848a7ccb3 --- /dev/null +++ b/benchmark/single-source/DropFirst.swift @@ -0,0 +1,193 @@ +//===--- DropFirst.swift ---------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +//////////////////////////////////////////////////////////////////////////////// +// WARNING: This file is manually generated from .gyb template and should not +// be directly modified. Instead, make changes to DropFirst.swift.gyb and run +// scripts/generate_harness/generate_harness.py to regenerate this file. +//////////////////////////////////////////////////////////////////////////////// + +import TestsUtils + +let sequenceCount = 4096 +let dropCount = 1024 +let suffixCount = sequenceCount - dropCount +let sumCount = suffixCount * (2 * sequenceCount - suffixCount - 1) / 2 + +@inline(never) +public func run_DropFirstCountableRange(_ N: Int) { + let s = 0.. Date: Wed, 12 Apr 2017 09:41:10 +0200 Subject: [PATCH 07/10] Added %swift_src_root substitution for lit tests. --- test/lit.cfg | 1 + validation-test/benchmarks/generate-harness.test-sh | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/test/lit.cfg b/test/lit.cfg index a08a49e7f141e..d17c522189912 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -354,6 +354,7 @@ ccp_opt = "-completion-cache-path %r" % completion_cache_path lit_config.note("Using code completion cache: " + completion_cache_path) config.substitutions.append( ('%swift_obj_root', config.swift_obj_root) ) +config.substitutions.append( ('%swift_src_root', config.swift_src_root) ) config.substitutions.append( ('%{python}', sys.executable) ) config.substitutions.append( ('%mcp_opt', mcp_opt) ) config.substitutions.append( ('%swift_driver_plain', "%r" % config.swift) ) diff --git a/validation-test/benchmarks/generate-harness.test-sh b/validation-test/benchmarks/generate-harness.test-sh index 0e77aaf796a86..a6c9175bbd47b 100644 --- a/validation-test/benchmarks/generate-harness.test-sh +++ b/validation-test/benchmarks/generate-harness.test-sh @@ -1,5 +1,5 @@ -// RUN: rm -rfv %t -// RUN: %swift_src_root/benchmarks/scripts/test_generate_harness.sh %swift_src_root %t +// RUN: rm -rf %t +// RUN: %swift_src_root/benchmark/scripts/generate_harness/test_generate_harness.sh %swift_src_root %t // REQUIRES: OS=macosx // REQUIRES: asserts // REQUIRES: CMAKE_GENERATOR=Ninja From 54cfe0a7c49181738c393e55eb019e3e51c9f41d Mon Sep 17 00:00:00 2001 From: Pavol Vaskovic Date: Thu, 13 Apr 2017 12:41:54 +0200 Subject: [PATCH 08/10] Nit: Fixed formatting of dashes in file header --- benchmark/single-source/DropFirst.swift | 2 +- benchmark/single-source/DropFirst.swift.gyb | 2 +- benchmark/single-source/DropWhile.swift | 2 +- benchmark/single-source/DropWhile.swift.gyb | 2 +- benchmark/single-source/PrefixWhile.swift | 2 +- benchmark/single-source/PrefixWhile.swift.gyb | 2 +- benchmark/single-source/Suffix.swift | 2 +- benchmark/single-source/Suffix.swift.gyb | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/benchmark/single-source/DropFirst.swift b/benchmark/single-source/DropFirst.swift index e8ea848a7ccb3..cc25cee28fc56 100644 --- a/benchmark/single-source/DropFirst.swift +++ b/benchmark/single-source/DropFirst.swift @@ -1,4 +1,4 @@ -//===--- DropFirst.swift ---------------------------------------------------===// +//===--- DropFirst.swift --------------------------------------------------===// // // This source file is part of the Swift.org open source project // diff --git a/benchmark/single-source/DropFirst.swift.gyb b/benchmark/single-source/DropFirst.swift.gyb index dc2c6a156fa13..c004ea094c451 100644 --- a/benchmark/single-source/DropFirst.swift.gyb +++ b/benchmark/single-source/DropFirst.swift.gyb @@ -1,4 +1,4 @@ -//===--- DropFirst.swift ---------------------------------------------------===// +//===--- DropFirst.swift --------------------------------------------------===// // // This source file is part of the Swift.org open source project // diff --git a/benchmark/single-source/DropWhile.swift b/benchmark/single-source/DropWhile.swift index 87be09076355e..2b377020d2fa6 100644 --- a/benchmark/single-source/DropWhile.swift +++ b/benchmark/single-source/DropWhile.swift @@ -1,4 +1,4 @@ -//===--- DropWhile.swift ---------------------------------------------------===// +//===--- DropWhile.swift --------------------------------------------------===// // // This source file is part of the Swift.org open source project // diff --git a/benchmark/single-source/DropWhile.swift.gyb b/benchmark/single-source/DropWhile.swift.gyb index 6452e166b3783..b8ef12f7b90c0 100644 --- a/benchmark/single-source/DropWhile.swift.gyb +++ b/benchmark/single-source/DropWhile.swift.gyb @@ -1,4 +1,4 @@ -//===--- DropWhile.swift ---------------------------------------------------===// +//===--- DropWhile.swift --------------------------------------------------===// // // This source file is part of the Swift.org open source project // diff --git a/benchmark/single-source/PrefixWhile.swift b/benchmark/single-source/PrefixWhile.swift index 169580118b0d4..480cfe706da33 100644 --- a/benchmark/single-source/PrefixWhile.swift +++ b/benchmark/single-source/PrefixWhile.swift @@ -1,4 +1,4 @@ -//===--- PrefixWhile.swift -----------------------------------------------------===// +//===--- PrefixWhile.swift ------------------------------------------------===// // // This source file is part of the Swift.org open source project // diff --git a/benchmark/single-source/PrefixWhile.swift.gyb b/benchmark/single-source/PrefixWhile.swift.gyb index f343fdf26d318..f276880c8dbc8 100644 --- a/benchmark/single-source/PrefixWhile.swift.gyb +++ b/benchmark/single-source/PrefixWhile.swift.gyb @@ -1,4 +1,4 @@ -//===--- PrefixWhile.swift -----------------------------------------------------===// +//===--- PrefixWhile.swift ------------------------------------------------===// // // This source file is part of the Swift.org open source project // diff --git a/benchmark/single-source/Suffix.swift b/benchmark/single-source/Suffix.swift index a8d1bd5707a46..4eb982af46927 100644 --- a/benchmark/single-source/Suffix.swift +++ b/benchmark/single-source/Suffix.swift @@ -1,4 +1,4 @@ -//===--- Suffix.swift ---------------------------------------------------===// +//===--- Suffix.swift -----------------------------------------------------===// // // This source file is part of the Swift.org open source project // diff --git a/benchmark/single-source/Suffix.swift.gyb b/benchmark/single-source/Suffix.swift.gyb index 145140c21f77b..87a65fed36439 100644 --- a/benchmark/single-source/Suffix.swift.gyb +++ b/benchmark/single-source/Suffix.swift.gyb @@ -1,4 +1,4 @@ -//===--- Suffix.swift ---------------------------------------------------===// +//===--- Suffix.swift -----------------------------------------------------===// // // This source file is part of the Swift.org open source project // From 6a54bc22ff3e1cdad26f789b2f25a69ed0d57ec1 Mon Sep 17 00:00:00 2001 From: Pavol Vaskovic Date: Thu, 13 Apr 2017 13:00:54 +0200 Subject: [PATCH 09/10] Fixed Python style issues reported by python-lint --- .../generate_harness/generate_harness.py | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/benchmark/scripts/generate_harness/generate_harness.py b/benchmark/scripts/generate_harness/generate_harness.py index 0b28ca31c6569..cb320588c0ea5 100755 --- a/benchmark/scripts/generate_harness/generate_harness.py +++ b/benchmark/scripts/generate_harness/generate_harness.py @@ -17,14 +17,15 @@ from __future__ import print_function import argparse -import jinja2 import os import re import subprocess +import jinja2 + script_dir = os.path.dirname(os.path.realpath(__file__)) perf_dir = os.path.realpath(os.path.join(script_dir, '../..')) -gyb_script = os.path.realpath(os.path.join(perf_dir, '../utils/gyb')) +gyb = os.path.realpath(os.path.join(perf_dir, '../utils/gyb')) single_source_dir = os.path.join(perf_dir, 'single-source') multi_source_dir = os.path.join(perf_dir, 'multi-source') parser = argparse.ArgumentParser() @@ -44,29 +45,33 @@ template_env = jinja2.Environment(loader=template_loader, trim_blocks=True, lstrip_blocks=True) -def all_files(directory, extension): # matching: [directory]/**/*[extension] + +def all_files(directory, extension): # matching: [directory]/**/*[extension] return [ os.path.join(root, f) for root, _, files in os.walk(directory) for f in files if f.endswith(extension) ] -def will_write(filename): # ensure path to file exists before writing + +def will_write(filename): # ensure path to file exists before writing print(filename) output_path = os.path.split(filename)[0] - if not os.path.exists(output_path): os.makedirs(output_path) + if not os.path.exists(output_path): + os.makedirs(output_path) + if __name__ == '__main__': # Generate Your Boilerplate - gyb_files = all_files(perf_dir, '.swift.gyb') + gyb_files = all_files(perf_dir, '.gyb') for f in gyb_files: relative_path = os.path.relpath(f[:-4], perf_dir) out_file = os.path.join(output_dir, relative_path) will_write(out_file) - subprocess.call([gyb_script, '--line-directive', '', '-o', out_file, f]) + subprocess.call([gyb, '--line-directive', '', '-o', out_file, f]) # CMakeList single-source - test_files = all_files(single_source_dir,'.swift') + test_files = all_files(single_source_dir, '.swift') tests = sorted(os.path.basename(x).split('.')[0] for x in test_files) # CMakeList multi-source From 857745fbf102d768bf016b535201357283341851 Mon Sep 17 00:00:00 2001 From: Pavol Vaskovic Date: Thu, 13 Apr 2017 21:38:21 +0200 Subject: [PATCH 10/10] Added usage comment to test driver. Renamed validation-test/[benchmarks -> benchmark]. --- benchmark/scripts/generate_harness/test_generate_harness.sh | 5 +++++ .../{benchmarks => benchmark}/generate-harness.test-sh | 0 2 files changed, 5 insertions(+) rename validation-test/{benchmarks => benchmark}/generate-harness.test-sh (100%) diff --git a/benchmark/scripts/generate_harness/test_generate_harness.sh b/benchmark/scripts/generate_harness/test_generate_harness.sh index ed1bb430e92c3..03421c29968b6 100755 --- a/benchmark/scripts/generate_harness/test_generate_harness.sh +++ b/benchmark/scripts/generate_harness/test_generate_harness.sh @@ -1,4 +1,9 @@ #!/bin/bash +# This script is invoked by `lit` on all smoke test runs from the +# validation-test/benchmark/generate-harness.test-sh. +# It ensures that the files checked in the benchmark suite that are generated +# from templates always match what would be regenerated if one +# re-ran the relevant scripts. This is to catch accidental manual edits. SWIFT_SRC_DIR="$1" BENCHMARK_DIR="${SWIFT_SRC_DIR}/benchmark" diff --git a/validation-test/benchmarks/generate-harness.test-sh b/validation-test/benchmark/generate-harness.test-sh similarity index 100% rename from validation-test/benchmarks/generate-harness.test-sh rename to validation-test/benchmark/generate-harness.test-sh